Try this :
$the_query = new WP_Query( array(
'post_type' => 'ad',
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'ad_category',
'field' => 'id',
'terms' => array('8')
)
)
));
posts_per_page
tells how many items you want to retrieve from DBorderby
tells to order items by date (optional as this is the default value)order
is set toDESC
to retrieve from newest to oldest items
Related Posts:
- Custom Post Type Plugin not loading category template and loading 404 instead
- Using WP Category Lists Plugin to Dynamically Display Category (PHP)
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Customize permalink wordpress category id
- Redirect to another page using contact form 7? [closed]
- .php file for woocommerce edit category? [closed]
- Categories from front-end, checkbox selection doesn’t work
- Precheck fields when I add a new post
- Display static pages instead of category, in code
- Disable email notification after change of password
- How can I allow commas in tag names?
- __(): What if I have to pass in a variable?
- Run WP-CLI using PHP
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Plugin update error message
- PHP Deprecated: Non-static method should not be called statically
- Restrict individual category combinations
- Set a User as Author of all ‘New Posts’ posted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Calling function from within functions.php returns unwanted value
- Check if a class exists within a method
- Set a category for a page
- Calling a plugin in theme development
- Unable to activate wordpress importer after installing it
- force customers to add only single item to card per purchase EDD [closed]
- How to get post URL in the_content filter?
- Write to / remove from default .htaccess file from plugin?
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- How to Use Parameters with a Do_Action Function Within PHP Tags
- WordPress JSON API remove posts from a specific category
- CSS from textarea in options page to frontend what to do
- How do I pass a post ID to the page URL?
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How to edit content before post update
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Take input from form and pass it to function using a wp-plugin
- Self-serve ad system like Reddit’s for WordPress? [closed]
- How to password protect a category page / not posts?
- Using arbitrary paths in page urls
- Create a plugin from within WordPress
- Class variables not correct on page
- Load Javascript from Plugin in One Page Only?
- Call plugin with php function
- Setting Up PHP Workflow in WordPress
- How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
- How do I add $_SESSION[”] to my wordpress page?
- output html on post or page from custom plugin [closed]
- How can i add simple code in only in posts by function.php
- Hide DIV if empty – Plugin Gallery
- Profile / benchmark wordpress on apache?
- Way to send multiple values for column to MySQL?
- Retrieve Plugin Settings and insert into XML string
- WordPress Stats Plugin: Display Post Views [closed]
- Pagination not working
- exec-PHP shows output at bottom of page
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Can I disable xml-rpc by setting it to false?
- How to hide featured images of all posts falling under the same category in wordpress?
- Getting current user data with MySQL statement
- how to validate input field in wordpress generated with wpform plugin
- Conditional delete metadata does not works
- Push Contact form 7 variable to front end after submission
- Add a parameter at the end of the url and prettify
- Share my WordPress plugin for updating how?
- How can I change page content for good once a button is pressed?
- Google Maps for Woocommerce Checkout
- working code, not working – Plugin Dev
- Add two row of code to the public static function init of a plugin
- Get and Update Most Meta Value as an array in HTML form
- Custom shortcode being shown in WPBakery backend rather than the block
- user specific private content
- Configuring default woo commerce login with modal popup
- submit form data to wordpress existing database table using my plugin
- register_activation_hook doesn’t fire at all
- My ajax request don´t work and return 0
- How can I remove this sidebar from my Search Results page?
- How to allow customers to input a text as a product variation *and* charge per character?
- conditional tags for the output of a plugin
- single.php fires more than once after clicking on any post to view with different post id each time
- Can’t insert files in other inputs
- How can I add the custom taxonomy categories to the posts and pages?
- How do I output user_registered time in my correct timezone?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Save post to category with gravity forms (post_data) [closed]
- Creating a press page for our project
- how to search through plugin in wordpress cimy-user-extra-fields?
- wordpress illegal string offset ‘parameter’ error
- Translate text for empty product
- How to add custom html to the Media > Attachment Details modal?
- Can i have limit posts on a specific category and automatically remove older ones?
- Option value not getting updated until page refresh in WordPress
- Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class