Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

WordPress custom post type

change your $args array to the following

$args = array(
    'post_type'   => 'product',
    'posts_per_page' => 5,
    'tax_query' => array(
        array(
            'taxonomy' => 'productcategories',
            'terms'    => $term->name,
            'field'    => 'name'

        ),
    ),
);

Related Posts:

  1. how to group custom post type posts by custom taxonomy terms
  2. How to get the parent’s taxonomy?
  3. Query for posts in 2 taxonomies
  4. Separate Posts and Custom Post Type in Custom Taxonomy archive template
  5. Display custom post type from dynamic custom field
  6. Query/list all terms and their custom post count
  7. Archive for custom taxonomy lists all posts instead of current taxonomy
  8. How to display Related Posts based on number of taxonomy terms matched
  9. How to make WP_Query not to show irrelevant posts?
  10. Custom post type, custom taxonomy, query posts only from taxonomy (children of)
  11. Sorting the Loop by Taxonomy Value
  12. custom post type and a “sticky” position taxonomy
  13. Use WP_query to match post types based on custom field values
  14. Values inside a custom field to determine which category posts to display
  15. orderby in custom WP Query does not work
  16. Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
  17. Display CPT posts based on specific taxonomy
  18. How to query custom post types posts filtered by multiple custom taxonomies through a form selection
  19. shortcode to show custom post types by category
  20. Filtering WP_Query Dynamically on the Front-End
  21. Why get_posts() not returning only selected category posts from Custom Post Type?
  22. Genesis filterable portfolio isotope [closed]
  23. wp_query check if integer exists in custom field’s array
  24. Wrong request query on cpt and tax
  25. Get custom taxonomies from multiple posts
  26. Pagination for Custom Taxonomy Page [duplicate]
  27. Get posts between custom dates
  28. Search / Filter posts on Title/Content OR Tags
  29. WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
  30. Custom-Posttype & Custom Taxonomy WP_Query
  31. Custom loop with multiple taxonomy queries
  32. How to use custom taxonomies to reference complex relationships?
  33. Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
  34. Query Custom posts of same taxonomy as the post itself
  35. Get latest 3 posts from multiple CPT in one query
  36. Conditional Query of Custom Post Type and custom taxonomy
  37. Show a Category X’s custom post type on Category X archive page?
  38. Custom taxonomy rewrite give pagination 404
  39. How to duplicate entire custom post type
  40. WP_Query inside foreach loop returning same value for all options when filtered using ajax
  41. Custom WP Query on custom meta and sort by multiple meta keys value
  42. WordPress loop: Show only a Custom Post Type Taxononmy TERM
  43. How can I made custom taxonomies relationship?
  44. What’s the WP way to load remaining custom posts?
  45. Custom taxonomies relationship
  46. Metabox not show in categories custom post type cmb2
  47. Polylang non-default language ignores tags in WP_Query
  48. WordPress request fiter order by related post’s post_title
  49. How to edit this code to get the categories in achieve page?
  50. How to have this permalink structure: post_type/postname/custom_inner_page
  51. Query Custom Post Type Taxonomy term with multiple parameters
  52. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  53. First custom field value (out of several) displayed twice after query
  54. Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
  55. WP_Query orderby and tax_query
  56. Different Ways to Query Custom Post Types?
  57. Listing all term items alphabetically / sorting loop
  58. Advanced search form with filters for custom taxonomies
  59. pagination not working for category.php (custom post types in categories)
  60. Why is my WP_Query outputting my entries twice?
  61. Retrieve custom post types by custom taxonomies with WP_Query
  62. WP the_posts() on single-cars.php get category link
  63. tax_query not working in template
  64. Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()
  65. Filter date from post meta when date is in string format
  66. Loop for custom post types filtered by a taxonomy
  67. WordPress wp_query() basic question about args
  68. Create an archive page for custom post type with custom taxonomy
  69. Using page slug in wp_query
  70. WP_Query() with custom post type and taxonomy — get all terms?
  71. Displaying a div from an assigned meta_value when on a page
  72. Custom query – get_the_terms not work
  73. Display different information of a custom post type
  74. Custom taxonomy wp_query woes.
  75. Variable not working in WP_Query
  76. WP_query – Filter by tax_query and meta_query using multiple select
  77. Creating two loops based on different logic
  78. Filter posts by tax (dropdown) and meta value
  79. Wp Query with multiple custom tag(taxonomy) by get the terms
  80. How to get specific post meta by title or id
  81. Control content before and after custom post type loop
  82. Display custom posts randomly in custom taxonomy archive
  83. WP_Query parameter conflict
  84. Not able to export large no. of posts in csv
  85. attach CPT data to a taxonomy
  86. how to show records that don’t have custom meta value
  87. how to get this tax_query working?
  88. Pagination not working on custom query on a page
  89. Targeting custom post type via functions.php doesn’t work
  90. find custom post type post by searching its custom field with my string
  91. FacetWP paging custom wp_query
  92. Different options per post type in WP_Query
  93. $post->post_meta not pulling any post in wordpress/php
  94. How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
  95. WP_Query of custom post type sorted by meta_key has unexpected results
  96. How to show all taxonomies within custom post type loop
  97. Returning a custom content types with meta values
  98. How to get the post terms from a child taxonomy
  99. Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
  100. display posts of custom post type with custom taxonomy
Categories custom-post-types Tags custom-post-types, custom-taxonomy, post-meta, query-posts, wp-query
How to add different link on each Post [closed]
Import xml feed

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress