Sorry I deleted my comment because I found the issue. You need to do an html entity decode on query variable. Use the code below.
function hey_query_shortcode( $atts ) {
extract( shortcode_atts( array(
'query' => '',
'style' => ''
), $atts ) );
$query = html_entity_decode( $query );
ob_start();
$the_query = new WP_Query( $query );
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<h2>I know $style is set bc it shows up here: <?php echo $style; ?></h2>
<h2>I know $query is set bc it shows up here: <?php echo $query; ?></h2>
<?php
endwhile;
echo '<hr>';
wp_reset_postdata();
$list = ob_get_clean();
return $list;
}
add_shortcode( 'postlist', 'hey_query_shortcode' );
Related Posts:
- How to paginate wordpress [gallery] shortcode?
- What kind of object type is WP_Query?
- Last post ordered by publish date using WP_Query on front page
- Shortcode returns escaped HTML tags
- WP_Query in a shortcode
- ‘&’ causes an error in my shortcode when I list the content of the page
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- How to retrieve current page WP_Query arguments?
- wp_query add arguments using array_push if variable met
- Category attribute not working in custom shortcode
- How to get all child pages in their parent page?
- Database Queries Optimization with new WP_Query
- Orderby is working with one query but not with other
- Shortcode for latest -not expired- posts
- Gallery shortcode numerical sorting
- How to filter a query by date in a shortcode?
- How should I approach changing the template & $query as part of a shortcode’s execution?
- Shortcode Not Working in Slider When Added To Post Title
- Shortcode for custom query not returning results when attributes are added
- How to Display Shortcode in the correct location, currently displaying before content after Page Title?
- WP_query only displays one of my custom post type entries
- Assign a minimum result count for WooCommerce query shortcodes?
- Using a Shortcode to List Posts from Multiple Categories
- embedding shortcodes in php template
- How to get specific string in explode array?
- Woocommerce Shortcode which displays a table with product data
- WP Query by 4 different taxonomies
- create custom shortcode wp and put php code in
- How to display a post(by id) along with css in a page?
- Shortcode attributes causes 500 error after updating the page
- pages shortcode filtering by category
- WP_Query & shortcode : Return 3 articles from a category WordPress
- Query by Category and Custom Field – Shortcode
- How to take parameters from a function and make them editable as attributes in a shortcode
- How to modify WP Query to target the first most recent post to adjust content
- Object of class WP_Query could not be converted to int inside shortcode
- How can I create another instance of my custom shortcode
- Get Current CPT taxonomy category in shortcode
- Custom shortcode not displaying categories and correct date
- return wp query results in a shortcode
- More efficient query to display posts in same sub-category?
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- shortcode using multiple WP_Query’s with multiple category names not fully functional
- Shortcode does not display pagination [duplicate]
- How to write a query-function as a query-shortcode?
- shortcode with $atts with strange results
- WP_query shortcode inside acf Repeater breaks the repeater loop
- How to prevent WP query searching in executed shortcodes
- why ignore_sticky_posts in sticky post query
- WP_Query by post ID doesn’t work if post is in custom post_status
- WP_Query orderby taxonomy term value (numeric)
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Display link to taxonomy archive only if it has posts with certain custom field values
- Display posts with date wordpress default
- WP Query Exclude and Start by Menu Order Offset
- Query total number of posts
- WP_Query Excluding pages with Order is 0
- WC displaying products from category
- Show all post for a given category
- pagination with numbers for WP_User_Query
- Stuck in the query loop
- Filter wordpress post categories with jquery/ajax and pagination?
- How to display the featured image for each post?
- How do I amend wp_query before it is run/executed?
- Is there a way to make this kind of loop shorter and nicer?
- WP Query ordering on a meta field for posts with a date in the future not ordering by datetime
- Merge 2 custom post type posts and taxonomy terms and sort ascending
- Pagination on template page for custom query redirecting to index.php
- how to get Nearby zipcode
- Exclude authors IDs from WP_Query
- Reload Query Loop When FacetWP Uncheck [closed]
- Exec wp query in slow motion to avoid memory error?
- Wpdb->query result show 1 but is not an integer
- Remove post type filter added by the plugin in the final query
- How to get more data of a post by wp_query
- WP_User_Query orderby meta_val_num
- Query Taxonomy By Page Title
- Unable to paginate a custom page query
- How to change the default post type over the loop?
- Determine if ID is page or post and query the ID
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- How do you do a meta query on an encrypted field?
- in_the_loop() issue with custom query
- Pagination inside the blog page not working
- How to restrict add media library only to images of the same post family?
- Wp Query sort order
- get_posts query caching?
- why doesn’t this pre_get_posts code work?
- pre_get_posts with WP_Query to prevent posts from specific tags
- Best way to Order Post in Home without a plugin
- Retrieving category pages from subcategory returns empty sets
- Shortcode display CPT Query only showing 1 post?
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- Get WP_Query query after execution?
- Display post format post in the sidebar