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
- How to create a three column blog layout with a single query and with three different classes?
- Use WP_Query with a custom SQL query
- Looping through tabular data
- Using next/previous_posts_link with customised search
- How to detect custom query inside `posts_where` hook?
- Is temporarily overwriting $wp_query a bad idea?
- Array Chunks and Inserting Varying HTML in WP_Query
- How to output different posts per page?
- Modifying the Search Results
- WP_Query times out
- How to find a post id using the post_excerpt?
- WP_Query filter and order by meta ordering by wrong joined table
- Querying A Post That Includes Two Taxonomies Using JSON Rest API
- WP_Query condition affects posts_per_page count
- Order by title without taking into account ‘the’
- Set global $wp_query/$post variable for dynamic page generation
- slow WP_Query for non-admin user
- Meta Queries – should nesting work after WP 4.1?
- Better wordpress attachment query than this
- How to number the posts (ie #1, #2, #3) in a wp_query?
- How can I check for a thumbnail in WordPress?
- WP_Query gives me different results depending on the category order
- Make a SQL query with wpdb in WordPress
- post_type argument not working correctly with WP_Query
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- WP query is calling get_userdata and throws error [closed]
- 2 column recent post query not respecting float right [closed]
- Add parameter to first post only
- using nav menu id’s
- Ignore image urls in wp_query search
- How to prevent WP_Query from filtering on ‘s’ but keep ‘s’ for other purposes?
- Query on meta values and post title
- Adding GROUP BY in Custom Query not working with ORDER BY
- Show custom content when loop or wp query reaches specific time?
- Query Order By Number Variable From API
- Wp includes access control
- Sorting query_posts() with a complex orderby filter
- How to exclude posts by ID within a category/archive loop
- Dynamically Update Page Content
- Optimal way to make tags in tax_query optional?
- Bring a post to the top of the query if it’s in a certain category?
- WP Meta Query at depth 2
- WP_query for posts with same post type AND same post category
- WP_Query is being reset after tag (using chaining method)
- Sorting Posts Based On Meta Value Using AJAX
- Sorting: custom query with orderby meta_value_num THEN by title
- WordPress Query showing multiple titles
- custom query to get posts
- Do not show a custom post if it belongs to a certain custom taxonomy
- on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query
- Block Editor – WordPress 6.1 – CPT Archive Issue – While the title changes in the loop, all records display the same data
- How to prevent random 302 canonical-ish redirect on custom template