Answer Posted / Rajendra Prasad Meena
To create a custom post type shortcode in WordPress, follow these steps:n1. Create a new plugin or edit an existing one.n2. 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.n3. Use [my_custom_shortcode] anywhere in your posts and pages.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers