So I see two things that could contribute to the problem:
- I really doubt you’ll need to
esc_attr
for the query. - This is a tricky one, but tax_query needs to be an array of arrays
Based on this, I believe this will work better for you:
$tax_query = array(
'taxonomy' => 'resources_categories',
'field' => 'slug',
'terms' => array( $category ), // <--------
'operator' => 'IN',
);
$args = array(
'post_type' => 'resources',
'post_status' => 'publish',
'posts_per_page' => $per_page,
'orderby' => $orderby,
'order' => $order,
'tax_query' => array($tax_query) // <--------
);
Hope this helps!
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
- 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?
- Trouble passing attribute into shortcode function
- 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
- WP_Query orderby date not working
- Best way to detect if you are in a SINGLE POST page
- Better way to get tag stats?
- Query two taxonomies via URL or link?
- wp_query order by title
- Sort posts by custom taxonomy name
- Wp_query order by multiple custom fields?
- Would this post meta be better added to the post table rather than post_meta table
- wpdb get results doesn’t work with variable
- Query Ignoring ‘exclude’ Parameter?
- Apply CSS class to every second database record [closed]
- Query posts by specific word on title
- Date and Category query with filter
- Get posts for which a custom field is not present, with get_posts
- Output an array of terms for a ‘tax_query’ => array()
- add active class based on permalink and url
- slow query – Search for Media Gallery
- WordPress has a list of reserved words, can I override them, to use one in a query string?
- How to order WP_Query to group results?
- new WP_Query messes up pagination
- get term id from term name
- Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute
- Use title of post as argument for query
- Different Loop for tag pages?
- Orderby two meta fields not working
- Multiple Query_Posts
- WP_Query: attachment image in “full” size?
- Adding pagination to sub-wp_query within a singular post page
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- get_post_format is not returning standard
- Get categories within specific term
- Exclude parent categories from recent posts list
- How can I query a radius of coordinates?
- custom excerpt is not being shown
- Filtering WP_Query based on wp_postmeta keys values
- meta_query only check if both value are set
- post_type not working when tag__in is present?
- How to create page that lists tags by initial letter?
- Seach and categories not working when ignoring sticky posts in main loop
- posts_per_page increment additional post
- WP_Query shows all posts on single post pages
- Display Count of posts
- Optimize WP_Query
- Add a custom variable to query page object
- Read more redirection problem
- Creating Custom Query
- Help in query for list links
- WP_Query issues with argument posts_per_page
- Search (Custom Form, Custom Search Result)
- Elementor custom query
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen