adspace


How do I create a post shortcode in wordpress?

Answer Posted / Rajendra Prasad Meena

To create a custom post type shortcode in WordPress, follow these steps:
1. Create a new plugin or edit an existing one.
2. In the plugin's PHP file, add the following code: function my_custom_post_shortcode() {n $args = array(n 'post_type' => 'my_custom_post',n 'posts_per_page' => 5,n );n $loop = new WP_Query($args);n if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();n the_title();n endwhile; endif;n }n Add this shortcode in your functions.php file or in a new shortcode plugin.
3. Use [my_custom_shortcode] anywhere in your posts and pages.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me how do I redirect users back to my blog's main page after they login?

253


Do you know what is the current version of wordpress?

242


How much is the wordpress business plan?

211