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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

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

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

PHP
哈士奇WWW 2023-09-22 17:05:16
我在 single.php 頁(yè)面上有一個(gè)有效的 '$lated = get_posts' 砌體。我還添加了一個(gè)懸停覆蓋層,以便當(dāng)用戶將鼠標(biāo)懸停在縮略圖上時(shí),會(huì)出現(xiàn)一個(gè)透明的覆蓋層以及描述(標(biāo)題名稱、類別和昵稱)。我面臨的問(wèn)題是,當(dāng)我將鼠標(biāo)懸停在一個(gè)相關(guān)帖子縮略圖上時(shí),每個(gè)帖子都會(huì)出現(xiàn)疊加層(疊加層被拉伸,不會(huì)單獨(dú)出現(xiàn))。我也嘗試過(guò)調(diào)用描述,但它只是調(diào)用我正在查看的當(dāng)前帖子(例如當(dāng)前的 single.php 標(biāo)題說(shuō) Snow ,當(dāng)我將鼠標(biāo)懸停在第一個(gè)相關(guān)帖子時(shí),它還會(huì)調(diào)用 Snow 的描述),但是,如果您單擊第一個(gè)相關(guān)帖子縮略圖,它會(huì)將您帶到另一篇文章(它不會(huì)調(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)題所述,如何通過(guò)將鼠標(biāo)懸停在 WordPress 的 single.php 頁(yè)面上的“$related = get_posts”來(lái)提取一篇文章的正確描述和覆蓋?
查看完整描述

1 回答

?
叮當(dāng)貓咪

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

我通過(guò)正確地重新組織代碼解決了這個(gè)問(wèn)題。


<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>


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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