Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

pre-get-posts

WordPress custom search form with pre_get_posts not work

August 6, 2022 by Magenaut

I am designing my first theme and I am stuck on the search functionalities of a Custom Post Type.
I created a CPT ‘movies’ and created the archive page with the ‘archive-movies.php’ file in the root of the theme folder. Inside I created a basic WP_Query

Categories Q&A, Wordpress Tags pre-get-posts, search, wp-query Leave a comment

How to choose between hooking into per_get_posts or into parse_query

August 6, 2022 by Magenaut

In refactoring my code base I noticed there are two hooks that used for modifying the main query.

Categories Q&A, Wordpress Tags hooks, pre-get-posts, wp-query Leave a comment

date_query in pre_get_posts out of memory

August 6, 2022 by Magenaut

I’m trying to apply a Datefilter for specific categories.

Categories Q&A, Wordpress Tags date-query, fatal-error, pre-get-posts, wp-query Leave a comment

How I can change the condition or compare operator for WP_Query in pre_get_posts

August 6, 2022 by Magenaut

So here is my problem
I want to show Posts if have same category if not have post then show post of same tag. And to do that I am using “pre_get_posts” action. and setting query like following.

Categories Q&A, Wordpress Tags get-posts, mysql, pre-get-posts, sql, wp-query Leave a comment

Formulate a url to show posts with both taxonomy terms

August 5, 2022 by Magenaut

I would like to show an archive of posts that have two taxonomy terms in common. So for example, I’d like to show all posts that have both the terms “sauce” and “cheese” in the custom food taxonomy.

Categories Q&A, Wordpress Tags multi-taxonomy-query, pre-get-posts, taxonomy, terms, wp-query Leave a comment

Can I alter the main loop to ‘orderby’ a custom callback?

August 5, 2022August 4, 2022 by Magenaut

I have a custom post type where the title is a name, and I want to sort the loop by the last word in title, the surname.

Categories Q&A, Wordpress Tags loop, pre-get-posts, wp-query Leave a comment

Using pre_get_posts with WP_Query

August 5, 2022August 4, 2022 by Magenaut

I was reading Stephen Harris‘s excellent answer to this question regarding the use of WP_query(), query_posts() and pre_get_posts.

Categories Q&A, Wordpress Tags pre-get-posts, wp-query Leave a comment

Using pre_get_posts on true pages and static front pages

August 4, 2022August 3, 2022 by Magenaut

I have done quite extensive research on how to use pre_get_posts on true pages and the static front pages, and it seems that there is no fool proof method.

Categories Q&A, Wordpress Tags frontpage, pages, pre-get-posts Leave a comment

When to use WP_query(), query_posts() and pre_get_posts

August 4, 2022August 3, 2022 by Magenaut

I read @nacin’s You don’t know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I’m a little bit wiser about using WP_Query(), but still have some gray areas.

Categories Q&A, Wordpress Tags get-posts, pre-get-posts, query-posts, wp-query Leave a comment

Include and Exclude Taxonomies From Archives & Feeds Using ‘pre_get_posts’

August 4, 2022August 3, 2022 by Magenaut

And you’re then assigning this array as the query_vars. Now the query_vars is a pretty large object. And you’re basically overwriting the data in there and just adding your custom ones. This means that you ‘unset’ everything that is added per default.

Categories Q&A, Wordpress Tags archives, custom-taxonomy, feed, pre-get-posts Leave a comment
Older posts
Page1 Page2 Page3 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress