Add custom post type taxonomy to shortcode atts
-
Hello,
I have created a custom post type that can be added to a page/post using a shortcode.
I am having difficulty in adding an attribute where the user can enter which category the posts should be displayed from.
My current shortcode code:
function my_sc($atts) { ob_start(); $sc_atts = shortcode_atts( array( 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'date', 'post_type' => 'rye_cpt' ), $atts ); $args = array( 'posts_per_page' => $sc_atts['posts_per_page'], 'order' => $sc_atts['order'], 'orderby' => $sc_atts['orderby'], 'post_type' => 'rye_cpt' ); return ob_get_clean(); } add_shortcode('shortcode','my_sc');
All the other attributes such as posts_per_page etc I’m just having difficulty for a category to be entered within the shortcode.
Any help much appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add custom post type taxonomy to shortcode atts’ is closed to new replies.