Skip to main content

All Questions

Tagged with
2 votes
1 answer
86 views

Equivalent of url_to_postid() for non-post URLs?

If I do url_to_postid("https://example.com/2024/05/test") I get back an int which I can then pass to get_post(). That works perfectly. But what if I request a tag or a year? What's the ...
Terence Eden's user avatar
0 votes
0 answers
20 views

How to make posts_like_dislike reference current post when iterating?

I am using plugin https://wordpress.org/plugins/posts-like-dislike/ . It adds a [posts_like_dislike] shortcode. When inside the default wordpress Twenty Twenty-Three in posts "Blog Home" ...
KamilCuk's user avatar
  • 101
0 votes
1 answer
33 views

Wordpress duplicating posts from single loop

I've created a custom post type with ACF custom fields included. The CPT is being placed inside of a bootstrap slider. Everything seems to be working, except, the posts being rendered on the page are ...
Mitch S's user avatar
  • 27
0 votes
1 answer
78 views

get_posts() function does not honor correct post type

I'm fetching all posts of a specific custom post type like below. print_r(ANCR_POST_TYPE); $announcements = array(); $announcement_posts = get_posts(array( 'post_type' => ANCR_POST_TYPE, // ...
Aakash Chakravarthy's user avatar
0 votes
1 answer
206 views

How to cache wordpress get_posts query using transients?

I have a website with over 100,000 posts. On a term taxonomy page, the main query WP_Query->get_posts() is the slowest. I want to cache the results of this query using transients-api. I tried ...
dc09's user avatar
  • 195
0 votes
1 answer
105 views

Sort by multiple columns using get_posts

I have the following: get_posts(array( 'post_type' => 'event', 'posts_per_page' => -1, 'meta_key' => 'start_date', 'orderby' => '...
mrtnmgs's user avatar
  • 137
0 votes
1 answer
76 views

filter on get_posts efficiently

I have posts with the following categories: A category that is a year(2017,2018...2022), a category that is type:(worldwide,Europe, local) I am trying to give users in the frontend advanced search ...
user206904's user avatar
0 votes
0 answers
139 views

Empty query on Custom Post Type, using WP_Query or get_posts

I've searched in SE and on Internet for 2 days without success. The problem is: I've a function that runs on "save_post_eventi" hook in WP backend dashboard, that starts with a simple query: ...
Manuel Serrenti's user avatar
0 votes
1 answer
160 views

complex get_posts() query to select child pages

I have pages on 2 levels under the main deparments page like below. Departments --Department 1 -----Course 1 -----Course 2 --Department 1 -----Course 3 -----Course 4 --Department 3 --Department ...
LeeTee's user avatar
  • 31
0 votes
0 answers
169 views

search.php to search only the post title

I'm trying to rewrite my search.php to search only for the post titles because I have a ton of posts published to my site (around 400k), which slows down the search speed to about 20s per search. <?...
Dardan Asllani's user avatar
0 votes
0 answers
200 views

How to add date_query to meta_query array

I am building a meta query array and all fields for the user are optional so some might not have any data. But there is also an option which requires a date query. I am still checking to see if this ...
user8463989's user avatar
0 votes
1 answer
201 views

date_query empty results with custom post type

I am trying to use get_posts to return data between certain dates but I always get an empty result even though there is a lot of data. This is for a custom post type. $args = array( 'post_type'...
user8463989's user avatar
0 votes
1 answer
111 views

Why my query is not "Main_query"?

I made a new page in admin panel like this. I want my Query here to be main_query so the other plugins could hook it, modify limits, etc... add_action('admin_menu', function (){ add_submenu_page('...
Movs's user avatar
  • 101
1 vote
1 answer
692 views

Get posts for which a custom field is not present, with get_posts

I'd like to get all posts for which the custom field hidden is NOT present. This does not work: $postsForSitemap = get_posts(array( 'numberposts' => -1, 'orderby' => 'modified', '...
Basj's user avatar
  • 85
0 votes
0 answers
127 views

Facing problem with tax_query results

I need to get search results for posts on the basis of post-category(must) and posts-tags(optional). The process is like: search for a string e.g. "bananas" the category is always static ...
Majid A.'s user avatar

15 30 50 per page
1
2 3 4 5
12