第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何防止砌體網(wǎng)格中“獲取相關(guān)內(nèi)容”的重疊?

如何防止砌體網(wǎng)格中“獲取相關(guān)內(nèi)容”的重疊?

PHP
哈士奇WWW 2023-09-22 17:05:16
我在 single.php 頁面上有一個有效的 '$lated = get_posts' 砌體。我還添加了一個懸停覆蓋層,以便當(dāng)用戶將鼠標(biāo)懸停在縮略圖上時,會出現(xiàn)一個透明的覆蓋層以及描述(標(biāo)題名稱、類別和昵稱)。我面臨的問題是,當(dāng)我將鼠標(biāo)懸停在一個相關(guān)帖子縮略圖上時,每個帖子都會出現(xiàn)疊加層(疊加層被拉伸,不會單獨出現(xiàn))。我也嘗試過調(diào)用描述,但它只是調(diào)用我正在查看的當(dāng)前帖子(例如當(dāng)前的 single.php 標(biāo)題說 Snow ,當(dāng)我將鼠標(biāo)懸停在第一個相關(guān)帖子時,它還會調(diào)用 Snow 的描述),但是,如果您單擊第一個相關(guān)帖子縮略圖,它會將您帶到另一篇文章(它不會調(diào)用不同文章的描述)。<div class="related">    <h3>Related</h3>    <div class="js-masonry">        <div class="overlay">            <?php $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'orderby' => 'rand', 'numberposts' => 3, 'post__not_in' => array($post->ID) ) );            if( $related ) foreach( $related as $post ) { setup_postdata($post); ?>            <a href="<?php the_permalink()?>"><?php the_post_thumbnail(array(300,300)); ?></a>            <?php } wp_reset_postdata(); ?>            <div class="posts">            <?php foreach((get_the_category()) as $category) {echo $category->cat_name . ' ';}?>          <h1><?php the_title();?></h1>          ————          <h4><?php the_author();?></h4>            </div>        </div>    </div></div>正如標(biāo)題所述,如何通過將鼠標(biāo)懸停在 WordPress 的 single.php 頁面上的“$related = get_posts”來提取一篇文章的正確描述和覆蓋?
查看完整描述

1 回答

?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗 獲得超12個贊

我通過正確地重新組織代碼解決了這個問題。


<div class="js-masonry">   

    <?php $args = array(

    'category__in' => wp_get_post_categories( get_queried_object_id() ),

    'posts_per_page' => 3,

    'orderby' => 'rand',

    'post__not_in' => array( get_queried_object_id() )

    );

    $the_query = new WP_Query( $args );

    if ( $the_query->have_posts() ) : ?>

    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    <div class="item-masonry overlay">

    <a href="<?php the_permalink();?>">

        <div class="posts">

            <?php foreach((get_the_category()) as $category) {echo $category->cat_name . ' ';}?> 

            <h1><?php the_title();?></h1>

            ————

            <h4><?php the_author();?></h4>

        </div>

        <?php the_post_thumbnail(array(300,300)); ?>

    </div>

    </a>

    <?php endwhile; ?>

    <?php wp_reset_postdata(); ?>

    <?php endif; ?>

</div>


查看完整回答
反對 回復(fù) 2023-09-22
  • 1 回答
  • 0 關(guān)注
  • 115 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號