Skip to main content

All Questions

Tagged with
0 votes
0 answers
28 views

How to Show Standard Post and Custom Post in Same Section at Homepage?

I'm trying to show both my standard posts and custom posts on my homepage. I've got the following code working, but it's causing a 404 error if I assign a custom homepage. If I keep the setting of &...
Ayushvam's user avatar
0 votes
2 answers
227 views

How to put posts with some taxonomy on top of others in `pre_get_posts`

The following tax_query returns only matched posts (with 'matchedstring' IN taxonomy array): function only_returns_matched_posts( $query ) { if( !$query->is_main_query() || is_admin() ) ...
mikmikmik's user avatar
  • 101
0 votes
0 answers
58 views

Search query alteration not working for meta values

The bellow code works on category archive pages, it filters out the necessary products. But on the search page it doesn't work. If I uncomment the line //$query->set("s", "chelsea&...
JorensM's user avatar
  • 101
0 votes
1 answer
131 views

Pre_get_post on CPT archive page

i would change the main query on a CPT archive page the CPT is declare as "events", the name of the archive page I use is called 'archive-events.php" and this simple code won't work. ...
nico's user avatar
  • 25
0 votes
0 answers
74 views

tax_query in pre_get_posts

I'm trying to add a tax_query for the query of a custom post type single page with this code. function wcua_pre_get_posts ($query) { // Also removed this condition if( is_admin() || ! $query-&...
Jose Adrian's user avatar
0 votes
1 answer
345 views

WP_Query - How to get all posts of specific days of week by custom field date?

I have a filter on frontend with days of weeks, and I need show only posts that are published on especific day (or days). The date are on custom field day_of_event (the filter is based on this field, ...
rafaelfndev's user avatar
0 votes
0 answers
718 views

Elementor posts custom query based on tag [closed]

How can I filter the Elementor Posts widget with a custom php query that returns posts with a specific tag attached? I want to do something similar to this: function my_query_by_post_types( $query ) { ...
ChristosDg's user avatar
3 votes
2 answers
1k views

Using pre_get_posts on a specific core/query block

I’m trying to apply the pre_get_posts to a specific core/query block, in order to programatically modify the number of posts displayed when a custom attribute is set. If I use the render_block hook, ...
Mark Howells-Mead's user avatar
0 votes
1 answer
870 views

How do I display main query posts in random order using add_filter

So I tried two methods to simply display the main query posts in random order - simple. I'm also trying to understand all this better. Using the_content add_filter, with my own instance of WP_Query ...
Mario's user avatar
  • 1
0 votes
1 answer
180 views

Replace wp_query with wp_user_query

I'm turning out some subscriber archives and singles (profile pages) in my plugin where I'd also included a 'user-single' template, included via template_include. I'm experimenting however with ...
Kevin Nugent's user avatar
1 vote
1 answer
457 views

Show scheduled posts in main loop but not in WP_Query?

The blog page should show scheduled posts in the main loop. I've done that with this code: /** * Show scheduled posts in main loop */ function fa_show_scheduled_posts( $query ) { if( $query->...
Elizabeth's user avatar
  • 357
0 votes
0 answers
144 views

Block internal search queries with pre_get_posts and regex rules

This relates to my previous question: Internal search spam (UPD: I no longer use Ivory Search) The closest question I found: Block search keywords As I understood, I need to use pre_get_posts, but I ...
Terry's user avatar
  • 1
0 votes
0 answers
231 views

Make a products only viewable to a specific user ID in meta_query pre_get_posts

I need to show some products to specific users set in the product itself by an ACF field that stores the user ID. I want to hide the product from the product category page / shop completely unless ...
Jake's user avatar
  • 69
0 votes
1 answer
241 views

queried_object using pre_get_posts gets notices and warning

My code is getting me the result I want on my page, I'm fetching another post and my theme is outputting all of the relevant data I need on the page as expected. function replaceQuery( $query ) { ...
Brendan Jackson's user avatar
1 vote
1 answer
137 views

How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?

Example: $query->set('s', 'foo bar'); - search foo bar I want set search as foo bar OR lorem ipsum dolor OR ping pong
Мегакот's user avatar

15 30 50 per page
1
2 3 4 5
10