Created
July 6, 2014 16:23
-
-
Save curtismchale/71a8f0bd70d2cd1965bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function demo_shortcode(){ | |
| $args = array( | |
| 'post_type' => 'product', | |
| 'meta_query'=> array( | |
| 'relation' => 'OR', | |
| array( | |
| 'key' => 'some_key', | |
| 'value' => '42', | |
| 'compare' => 'IN', | |
| ), | |
| array( | |
| 'key' => 'some_key', | |
| 'compare' => 'NOT EXISTS', | |
| ), | |
| ), | |
| ); | |
| $new_posts = WP_Query( $args ); | |
| // the loop | |
| if ( $new_posts->have_posts() ) : while ( $new_posts->have_posts() ) : $new_posts->the_post(); ?> | |
| <!-- post content goes here --> | |
| <?php the_title(); ?> | |
| <?php endwhile; else: ?> | |
| <h3>Oops!! Looks like something went wrong. Please get in touch with the site <a href="mailto:<?php echo get_bloginfo('admin_email'); ?>">administrator</a> and we'll get this sorted out</h3> | |
| <?php endif; ?> | |
| <?php wp_reset_postdata(); | |
| } | |
| add_shortcode( 'demo_code', 'demo_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment