Articles of wp query

Include tags in WP_Query

I found several posts about it. Others said that you cannot do it without a plugin and others that it is possible. However, I am not sure what is true 😛 This is my query and unfortunately, I cannot make it return objects with a certain tag. <?php global $query_string; $query_args = explode(“&”, $query_string); $search_query […]

Date and Category query with filter

I am a little confused by this. I have a query that finds posts within a category and date. I can filter the categories, but I have no idea how to filter by date. The query works. I see all of the posts I have queried, but I don’t know how to filter the date. […]

Paging + WP Query

On every archive page I’m either using WP-queries and no paging, or paging without a WP-query and a regular old “if(have_posts)” Now on one archive page I want to display more than 8 posts (8 is in settings for all my normal archive pages) So I thought about using a WP-query, but when I use […]

How to restrict search on a certain page to only return results against custom taxonomies?

On a specific page, I would like the search to be performed only against the terms from two custom taxonomies. Not the content or title. That is, the user is directly searching taxonomy terms. What I’m trying to do is completely rewrite the query for searches, but it doesn’t seem to work. function search_filter_get_posts($query) { […]

How to get old posts instead of recent with WP_Query?

I’m doing a WP_Query with a date_query parameter after, and I want the nearest post after that date, but I get the farest ones in the future from the date. Is there any parameter to control this? something like ‘near_to’ => ‘past/future’, or WP_Query always retrieve the most recent? This is my code: $my_query = […]

Child pages not affected by orderby

My loop won’t order the child pages I’m displaying in the order I want them to, neither ASC or DESC. I’ve already seen many other similar issues, but those were resolved with disabling plugins (which I don’t have) or removing or adding quotes (which I’ve checked multiple times). <?php $args = array( ‘post_type’ => ‘page’, […]

Display recent posts on another site

I have created a recent post type plugin and it displays recent posts from another website, but the permalinks are not working properly. The permalink does not show the post’s URL, it shows the same website URL. Can anyone help me? Here is my own code: // db parameters $db_hostname = ‘localhost’; $db_username = ‘root’; […]

Querying a large number of posts including their custom fields data

I’m building a SVG map separated into about 200 regions. For each region there are attributes that describe it, as well as a region ID. These regions are just polygons in the SVG. I setup a custom post type so that the data associated with these regions could be added in the dashboard, and upon […]

Get the child category ID of current category

I am trying to get the category ID of the child (no grand children) of the current category. Using below method: $category = get_category(get_query_var( ‘cat’ )); // get category ID $catid = $category->cat_ID; I can get the current category ID. However, using this in WP_Query result in displaying the posts that are published in Parent, […]

Query posts by specific word on title

Is it possible to query posts by a specific word on title? Example: I have 3 posts inside my blog and only two have the word car on the title. She wants a ride on my truck My car is super fast Her car is yellow If this is possible, query should return only posts […]