All Questions
170
questions
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 ...
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" ...
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 ...
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, // ...
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 ...
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' => '...
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 ...
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:
...
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 ...
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.
<?...
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 ...
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'...
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('...
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',
'...
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
...