We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在后台可以添加或删除logo。
需求解剖: logo数量不一定,需要把它放在文章的自定义栏目中以一个关键词承载并在代码中打印出来。
<?php $my_query = getMy_query(1,"轮播logo"); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); $image = get_post_meta ( $post->ID, 'image', false ); for ($x=0; $x<sizeof($image); $x++) {;?> <img src="<?php echo $image[$x];?>" alt=""> <?php } endwhile; wp_reset_query(); }else{ ?> <p> 暂无数据 </p> <?php } ?>
$my_query = getMy_query(1,"轮播logo") 从分类为轮播logo的分类中查找一篇文章 if( $my_query->have_posts() )如果查询到有文章的话 while ($my_query->have_posts()) : $my_query->the_post() 当有文章则调用文章 $image = get_post_meta ( $post->ID, 'image', false ) 取名字为image的自定义栏目, false表示以数组方式展示,true表示只取第一个 for ($x=0; $x<sizeof($image); $x++) {;?> 循环打印image里面的内容,sizeof()函数返回image数组的长度 <img src="<?php echo $image[$x];?>" alt=""> 打印出url
$my_query = getMy_query(1,"轮播logo")
if( $my_query->have_posts() )
while ($my_query->have_posts()) : $my_query->the_post()
$image = get_post_meta ( $post->ID, 'image', false )
for ($x=0; $x<sizeof($image); $x++) {;?>
<img src="<?php echo $image[$x];?>" alt="">
打开浏览器就可以看到图片渲染出来啦。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原始需求
需求解剖:
logo数量不一定,需要把它放在文章的自定义栏目中以一个关键词承载并在代码中打印出来。
那怎么循环打印呢?
$my_query = getMy_query(1,"轮播logo")
从分类为轮播logo的分类中查找一篇文章if( $my_query->have_posts() )
如果查询到有文章的话while ($my_query->have_posts()) : $my_query->the_post()
当有文章则调用文章$image = get_post_meta ( $post->ID, 'image', false )
取名字为image的自定义栏目, false表示以数组方式展示,true表示只取第一个for ($x=0; $x<sizeof($image); $x++) {;?>
循环打印image里面的内容,sizeof()函数返回image数组的长度<img src="<?php echo $image[$x];?>" alt="">
打印出url打开浏览器就可以看到图片渲染出来啦。
The text was updated successfully, but these errors were encountered: