How do I create a post shortcode in wordpress?
Answer / 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 |
Is wordpress a software?
Is wordpress secure?
How we can disable comments in wordpress?
How can you create a static page with WordPress?
How to find out number of parameters passed into function?
Is backupbuddy free?
What is the function of wordpress?
Explain which is the best multi-lingual plugin for wordpress?
Can you have 2 themes in wordpress?
Why is my wordpress not publishing?
Can I download wordpress for free?
How to find out the number of parameters passed into function?