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:
This will filter the posts by all the settings applied Posts Query Section.
Select specific posts to display by name. (can mix diffrent post types)
Show a list of posts related to the current viewed 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.
If this option is selected, posts which are configured as sticky will be included in the post list.
Show only posts which are configured as sticky posts.
Show posts related to a specific author or multiple authors. Under this option you can also select logged in user.
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.
Show children posts of any given post parent.
Use meta key to show posts assigned only to those keys.
Show the most viewed posts by integrating with 'WordPress' popular posts plugin.
Get post id's array from a PHP function.
4. Include By Term
Show posts related to a specific taxonomy. For example assigned to a category.
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.
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.
Exclude posts assigned to a specific term.
If the widget is displayed in a specific page or post you can exclude it from the selection.
Exclude posts assigned to a specific author or multiple authors.
Exclude posts that do not have a featured image assigned to them.
Exclude posts from the current viewed category in your selection.
Exclude posts from the current viewed tag in your selection.
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.
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.
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.