Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('find_my_special_posts', 'find_my_special_posts');
- function find_my_special_posts() {
- $posts = new WP_Query(array(
- 'posts_per_page' => -1,
- 'post_type' => 'post',
- 'tax_query' => array(array(
- 'taxonomy' => 'category',
- 'field' => 'slug',
- 'terms' => 'random-post-term'
- ))
- ));
- $output = '';
- while ($posts->have_posts()) {
- $posts->the_post();
- $output .= '<p>' . get_the_title() . '</p>';
- }
- wp_reset_postdata();
- return empty($output) ? "<p> Sorry matey but you're out of luck. </p>" : $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement