Add custom post type title and category to shortcode attribute
-
Hello,
I currently have a shortcode that can display a list of posts (custom post types)
I have added a couple of attributes that if used display with no problems.
How can I add the post’s title, id and category as attributes?
Code I’m using within the shortcode function:
extract( shortcode_atts( array( 'posts' => -1, 'order' => '' ), $atts ) ); $args = array( 'posts_per_page' => $posts, 'order' => $order, 'post_type' => 'mws_faqs' ); $query = new WP_Query( $args ); while ( $query->have_posts() ) : $query->the_post(); ?> <div> <h3><?php echo the_title(); ?></h3> </div> <?php endwhile; wp_reset_postdata(); ?>
Any help much appreciated
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Add custom post type title and category to shortcode attribute’ is closed to new replies.