admin管理员组文章数量:1405133
How to get current ID for WP Loop in my case?
I try to loop the GIVEWP (Success), then I try to echo shortcode of GOAL Progress Bar of GiveWP but the problem is, i don't know how to get the current ID.
Here my code:
<?php while ( have_posts() ) : the_post(); ?>
<!-- LOOP -->
<?php echo do_shortcode('[give_goal id="INEEDCURRENTIDHERE" show_text="true" show_bar="true"]'); ?>
<!-- END LOOP -->
<?php endwhile; // end of the loop. ?>
Thank you. :)
How to get current ID for WP Loop in my case?
I try to loop the GIVEWP (Success), then I try to echo shortcode of GOAL Progress Bar of GiveWP but the problem is, i don't know how to get the current ID.
Here my code:
<?php while ( have_posts() ) : the_post(); ?>
<!-- LOOP -->
<?php echo do_shortcode('[give_goal id="INEEDCURRENTIDHERE" show_text="true" show_bar="true"]'); ?>
<!-- END LOOP -->
<?php endwhile; // end of the loop. ?>
Thank you. :)
Share Improve this question edited Dec 26, 2019 at 7:59 Chetan Vaghela 2,4084 gold badges10 silver badges16 bronze badges asked Dec 26, 2019 at 6:58 Syafiq FremanSyafiq Freman 1013 bronze badges 2- 1 Get current id in while loop $id = get_the_id(); then use id in shortcode like do_shortcode('[give_goal id="'.$id.'" show_text="true" show_bar="true"]'); – Chetan Vaghela Commented Dec 26, 2019 at 7:29
- 1 Thanks @ChetanVaghela . It's works! :) – Syafiq Freman Commented Dec 26, 2019 at 8:11
1 Answer
Reset to default 0Try using this:
$post_id = get_the_ID();
OR
global $post;
$post_id = $post->ID;
OR
$post = $wp_query->post;
$post_id = $post->ID;
本文标签: pluginsGet Current Post ID in WP Loop For GiveWP
版权声明:本文标题:plugins - Get Current Post ID in WP Loop For GiveWP 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744879304a2630108.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论