Unanswered Questions
2,878 questions with no upvoted or accepted answers
6
votes
2
answers
2k
views
Admin Area Custom Type Search By Meta Fields Without Title & Content
I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code:
...
5
votes
1
answer
1k
views
Order wp_query by calculated field
Hi I'm working on a store locator.
I have a custom post "clinics" where I save clinic details (address,.., lat, lng). Each time I publish a new clinic I save post_id, lat and lng also in a custom ...
5
votes
1
answer
12k
views
wp_query->max_num_pages always returns 0 on custom post type
Hi there I am developing a theme where I have to load some posts with ajax, in my index page everything works properly, the problem is when I need to use it on custom post type, I pass the values for ...
5
votes
2
answers
790
views
Extending WP_Query — Optimise SQL query
I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows:
class ...
4
votes
0
answers
3k
views
Correct processing of `$_POST`, following WordPress Coding Standards
Background
I'm building a project that according to the specifications need to follow the WordPress Coding Standards. I am using phpcs to scan my code.
If I try to pass $_POST-data into a function ...
4
votes
1
answer
2k
views
Exclude custom taxonomy from search results and archive pages
UPDATE:
I have the following code working. It excludes the taxonomy from the search results. However, I would like this only to happen if a user is not logged in. The code below is taking effect for ...
4
votes
1
answer
1k
views
get_post_meta returning empty string when data shows in the database
I'm absolutely stumped and I'm hoping this is something stupid that I just can't see because I'm too close to it.
Working on an LMS using Sensei. Trying to get the course_id from a lesson. Pretty ...
4
votes
1
answer
3k
views
WP_Query min and max values
I'm building a houses class and I want to filter these houses with a query. But don't get any results:
Example house:
Min price: 10
Max price (field not required): empty
I've a price filter ...
4
votes
1
answer
117
views
How do I get the total number of categories in a list of search results?
I want to display the total count of categories in a set of search results.
For example, "10 posts found in 3 categories." (Assuming that each post has only 1 category.)
Right now, my solution is to ...
4
votes
1
answer
406
views
publish_post action hook doesn't give post_meta_data
I write the following function to get the post data on publish post but i see that post_meta is not available, its always empty. How do i retrieve the post meta data of a post on publish_post hook?
...
4
votes
0
answers
510
views
Should I hint table index for search query on wp_post
I'm currently inspecting a WordPress setup with multiple custom post types that should be included into search results.
The database query for a search after the word Search looks like this:
SELECT ...
4
votes
2
answers
2k
views
How do I order pages and categories by ID or name in the same query?
I would like to query most of my pages and categories on the homepage. So far I am able to get the pages and category (posts), but I cannot order the list the way I want to. I want to be able to get a ...
4
votes
1
answer
644
views
Get page content by category or tag
I'm trying to sort of emulate the Views behaviour in Drupal with WordPress, but doing it in theme templates.
Now, I have pages that are assembled by using wp_query in the template to get posts ...
3
votes
0
answers
134
views
How do I manage custom meta in post revisions in the Block Editor era?
Note to admins: I have been trawling every possible resource for this but cannot find a good answer for modern WordPress, so please don't mark this as a duplicate of ("insert some answer from ...
3
votes
1
answer
296
views
searching in custom meta field
I have multiples custom field in a post type. i can save data, update and display, all fine. now I'm doing the search engine. as it is a library, it must be possible to search in specific fields (...