Find the php file for shortcode in customtheme :
File Location:
webroot\wp-content\themes\themename\backend\shortcode.php
Find the below code :
File Location:
webroot\wp-content\themes\themename\backend\shortcode.php
Find the below code :
function recent_blog($atts) { extract(shortcode_atts(array('limit' => '3', 'number' => '3','fullpage' => 'no' ), $atts)); $number = $limit; $categoryid = $category; // added category slug here... $wp_query = new WP_Query( array( 'post_type' => array('post'), 'showposts' => $number, )); .................... add_shortcode('recent_blog', 'recent_blog');add category , category_name - category slug name to filter the post by category
function recent_blog($atts) { extract(shortcode_atts(array('limit' => '3', 'number' => '3','fullpage' => 'no', 'category'=>'' ), $atts)); //added slug category here......'category'=>'' $number = $limit; $categoryslug = $category; // added category slug here... $wp_query = new WP_Query( array( 'post_type' => array('post'), 'showposts' => $number, 'category_name' => $categoryslug , // added category slug here... )); ............. add_shortcode('recent_blog', 'recent_blog');Use following shortcode on page/post in content area
[recent_blog limit="5" fullpage="yes" category="slugname"]
No comments:
Post a Comment