簡體   English   中英

WordPress,使用自定義循環在滑塊中顯示特定類別帖子的自定義字段內容

[英]Wordpress, displaying custom fields content of specific category of post, in a slider, using a custom loop

我是PHP的初學者,也許有人可以幫助我...

我有這個滑塊,當我在其中使用不同的圖像時可以使用:

<a id="prev1">prev</a><a id="next1">next</a>
<div id="slider">
  <img src="/images-custom/telephone-icon.jpg"/>
  <img src="/images-custom/mail-icon.jpg"/>
  <img src="/images-custom/linkedin-icon.jpg"/>
</div>

但我不想使用圖像,而是要使用自定義循環在滑塊中顯示自定義字段和固定鏈接。

這是我的循環:

<?php 
$catquery1 = new WP_Query( 'cat=9&posts_per_page=1&orderby=date&order=ASC' ); 
while($catquery1->have_posts()) : $catquery1->the_post(); ?>

<?php the_field('slogan_dactualites_sur_la_page_accueil'); ?>

<?php if($GLOBALS['q_config']['language']=="en"){ ?>
    <a href="<? the_permalink(); ?>">Read more</a>
<?php }else{ ?>
    <a href="<? the_permalink(); ?>">Lire la suite</a>
<?php } ?>
<?php endwhile; ?>

如果有人可以幫助我,將不勝感激!!! 謝謝

由於您尚未說明正在使用的滑塊,並且無法分辨此滑塊的局限性,因此我的代碼完全未經測試或保修。

<a id="prev1">prev</a><a id="next1">next</a>
<div id="slider">

$catquery1 = new WP_Query( 'cat=9&posts_per_page=1&orderby=date&order=ASC' ); 
while($catquery1->have_posts()) : $catquery1->the_post(); ?>
    <div class="slider-element">
    <?php the_field('slogan_dactualites_sur_la_page_accueil'); ?>

    <?php if($GLOBALS['q_config']['language']=="en"){ ?>
        <a href="<? the_permalink(); ?>">Read more</a>
    <?php }else{ ?>
        <a href="<? the_permalink(); ?>">Lire la suite</a>
    <?php } ?>
    </div>
<?php endwhile; ?>
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM