Introduction:
In this article, you will learn about various options and settings available in the Post Query Section for any Post Widget or Loop Widget in the widget library for example: Post Grid, Post Carouse, Post list, etc.
1. Post Source #
Allows us to select the source for your posts output. These are the options available:
Custom Posts
This will filter the posts by all the settings applied Posts Query Section.
Manual Selection
Select specific posts to display by name. (can mix diffrent post types)
Related Posts
Show a list of posts related to the current viewed post.
Current Query Post
Used in an archive page to display posts from a WordPress query.
2. Post Types #
You can choose the relevant post type you want to display in your post widget. For example: posts, pages, products or any custom post post type. You can select more than one post type since this is a multi select field.
3. Include By #
You can choose the relevant post type you want to display in your post widget. For example: posts, pages, products or any custom post post type.
Include Sticky Posts
If this option is selected, posts which are configured as sticky will be included in the post list.
Get Only Sticky Posts
Show only posts which are configured as sticky posts.
Author
Show posts related to a specific author or multiple authors. Under this option you can also select logged in user.
Date
Include posts by a predefined date range or a custom date range. Use custom fields for date ranges to override the default WordPress post date.
Post Parent
Show children posts of any given post parent.
Post Meta
Use meta key to show posts assigned only to those keys.
Most Viewed
Show the most viewed posts by integrating with 'WordPress' popular posts plugin.
ID's from PHP function
Get post id's array from a PHP function.
ID's from Post Meta
ID's from Dynamic Field
4. Include By Term #
Show posts related to a specific taxonomy. For example assigned to a category.
Include By Terms Relation
This option is relevant only when more than one term is selected. If set to AND the post will need to be assigned both terms for example. If set to OR then it can be assigned to either terms.
Include Terms Children
Decide if to show children of a parent term in your selection.
5. Exclude By #
Choose specific posts that you would like to exclude from your selection by adding rules.
Terms
Exclude posts assigned to a specific term.
Current Posts
If the widget is displayed in a specific page or post you can exclude it from the selection.
Author
Exclude posts assigned to a specific author or multiple authors.
Post Without Featured Image
Exclude posts that do not have a featured image assigned to them.
Posts with current category
Exclude posts from the current viewed category in your selection.
Posts with current tags
Exclude posts from the current viewed tag in your selection.
Offset
Show posts only from a certain number. For example you have 50 posts in your selection if offset is set to 10 then you will see only 40 posts from post number 10.
Avoid Duplicates
If more than one post widget on the page do not show the same post more than one time on the page. If in your selection the widget finds a duplicate it will skip it.
ID's from Dynamic Field
6. Post Status #
This setting allows you to select the post status for post selection. You can select by published, pending review, private, future, draft or inherit.
7. Max Posts #
Set the number of maximum posts to display. If left empty will show up to 100 posts.
8. Order By #
This setting determines the order of the posts. Post ID, Date, Title, Slug, Author, Last Modified, Number Of Comments, Random, Unsorted, Menu Order, Parent Post, Preserve Posts In Order, Custom Field Value, Custom Field Value (numeric)
You can also determine the Order By Direction in a descending or ascending order.
9. Query ID #
Give your Query a unique ID to be able and filter it in the server side using add_filter() function.
This is how you do it:
//modify the arguments here.
//widget data is an array with all widget settings
function modifyMyQuery($args, $widgetData){
return($args);
}
add_filter("my_query_additions", "modifyMyQuery",10,2);
10. Show Query Debug #
This advanced mode will show the post query selection for debugging purposes. Don’t forget to turn it off before page release.