[英]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.