A generic term referring to the process of retrieving information from a database.

learn more… | top users | synonyms

0
votes
0answers
4 views

How to obtain a list of root-level menu items that have children?

I'm working on an admin panel that offers some minor customization for nav items that have sub-menus - naturally, to that end, it would be really handy to get a list of all root-level menu items that ...
0
votes
0answers
21 views

How to execute a SQL-query which contains multiple queries using $wpdb->query?

I want to execute the following Query-String, which contains 2 separate queries using $wpdb->query: CREATE TABLE `foobar` ( `id` int(2) NOT NULL AUTO_INCREMENT, `foo` varchar(22) COLLATE ...
0
votes
1answer
18 views

WP_Query always returning the last custom post

I have code that works fine on our live system, and I'm porting it to a new theme. In the new theme, the WP_Query always seems to return the last custom post. My function is: function ...
0
votes
0answers
25 views

2 different templates for 1 query

I have a working query with some custom meta fields (among others ACF Gallery field) which displays news on "News" page. I have also second page named "Gallery" which is quering posts by gallery ...
3
votes
1answer
791 views

Random post, once per day

I have a custom post type 'quotes' and I would like to display a random entry on the homepage each day. This is the code I currently have to display the content: <?php query_posts( ...
0
votes
0answers
6 views

Querying same column twice with wpdb (for postmeta values, specifically latitude and longitude)

I've seen similar questions around, but I just can't apply them to my case, I'm quite new at this, apologies. I'm trying to create a google map of my posts, using a latitude and longitude that are ...
1
vote
1answer
25 views

How many queries are normal to execute on a WP site?

I use the following PHP code in my theme's footer. <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds. Then I realized that about 140 to 210 queries are ...
0
votes
1answer
15 views

WP_Query secondary query failing

I'm needing a couple queries on front-page.php and am at a loss why this is not working. My first query works fine, however, my second one specifying the category (or even nothing at all) never ...
0
votes
2answers
29 views

Get Posts that are in the current month or later

I have a custom post type that is an Event. I'm trying to query those Events and only return Events that are in the current month or later. So the event could be in the past, but it has to be in the ...
0
votes
1answer
25 views

Run an update query in a function

I need to run the below in a function, it updates my database if certain conditions are met. I can't get it to work and I can only assume its because of the "SET @newnum" at the beginning. I've ...
0
votes
1answer
11 views

What is the best way to query posts based on live data?

I work on developing plugin for WordPress. In each post, there are rating bar that users can rate 1-5 star to post. I calculate the grow rate based on (Stars in past 7 day from now). I want to show ...
0
votes
1answer
31 views

Get list of taxonomies associated with users

I've seen Justin Tadlock's post on creating taxonomies for users, so I know that it's possible to do that. But how do you get a list of all of the taxonomies associated with users? For posts and CPTs ...
0
votes
0answers
33 views

How to search posts by title, id and author? [duplicate]

i am getting the details from a custom search with the below query from a parameter $_REQUEST['search'] in the URL $custom_args = array( 'post_type' => 'post', 'posts_per_page' => 5, ...
0
votes
0answers
40 views

Filtering posts in query

I might be way over my head with this one, but I'm trying to get WP to filter posts by two taxonomies (categories & kategoriat) and one custom meta value (date), so you can filter between dates ...
0
votes
0answers
16 views

Is it possible to use an OR (instead of AND) between tax_query and s (search) in a query?

In the following example: $search = 'thing'; $query = new WP_Query(); $query->query( array ( 's' => $search, 'tax_query' => array( array( ...
0
votes
1answer
19 views

How to make an insert in wp_posts and use the data inside of WordPress? [on hold]

I need to do a vehicle system and would like to know how to use the wp_insert function to insert data in the Wordpress database. I must also know how to enter the meta values. Example : color, size ...
0
votes
0answers
23 views

Displaying multiple custom meta fields on the fronted

I am trying to simplify how I display multiple metabox entries on my front page through a custom theme panel. As of right now I have a custom panel called explore which is programmed in my custom ...
0
votes
0answers
42 views

Fake post on the fly with ajax

I would like to generate one fake post on the fly in the admin panel. My aim is to use fake content to retrieve the_title(), the_content(),the attachement url,... I will use this to display different ...
0
votes
1answer
34 views

merge two query arguments into one WP_Query call

I'm overriding WooCommerce's default search query to include searching by SKU as well. // default search query $query_default_search = new WP_Query( array( "post_type" => "product", ...
0
votes
0answers
29 views

How to get query results for the next page

How to get query for posts from next and previous pages on Blog via ajax call? I'm thinking about making copy of the current query with offset like this: $curr_query = new WP_Query( array( ...
0
votes
1answer
22 views

Custom Select Query pagination not working properly

I have Custom Select Query joining two tables and displaying events older than current date. Everything works fine until I try to paginate it. <?php global $wpdb; $date = ...
0
votes
1answer
36 views

Custom select query two tables by a meta key

I'm using an event plugin which creates wp_ftcalendar_events table in database with start_datetime column. Here's image of whole table: I want to query my posts by start_datetime. I know that I ...
0
votes
0answers
11 views

Sorting taxonomies by count of posts with another taxonomy

I'm trying to create a widget that does the following: We have 2 taxonomies here, "brands" and "topic" The widget is supposed to display the 8 brands with the most posts in "topic" on the "topic" ...
0
votes
1answer
54 views

Include custom table in query

Im using event calendar plugin where I can set event date for posts and it shows in calendar widget. Everything is working as inteded but I would also like to query post by event date. Problem is ...
0
votes
1answer
33 views

Query Pulling the same post twice

After seeking help and failing, I managed to write a query for Wordpress that does exactly what it's suppose to do, however it pulls the post that it's suppose to in twice. I've stared and stared at ...
0
votes
0answers
21 views

loop all posts by category

I have custom post type and taxonomy. post_type = product taxonomy = Products 2 level of taxonomy. Living room -Sample tax under living room -more -more Kitchen -sample tax under Kitchen -more -more ...
0
votes
1answer
28 views

How to fix this insert? Don't work for me!

I need to fix errors of this insert because this don't work in my script. I'm a beginner in WordPress SQL. Thanks $wpdb->insert('wp_cadastrados', array ( 'ID' => NULL, ...
0
votes
0answers
28 views

Querying on a custom post type without tags returns no posts

A theme I'm working on contains a custom post type, "help_question", which is declared as such in functions.php add_action( 'init', 'create_post_type' ); function create_post_type() { ...
0
votes
0answers
11 views

Query if audio attachment AND/OR custom field

I've been trying several things but to no avail... Searched, maybe not good enough though! I have posts that either have an uploaded audio file AND/OR has a Soundcloud link (which is a custom field). ...
0
votes
0answers
18 views

Add generic page to WP_Query

I have a query that gets all my custom post types of Service. I need to add a generic page (Classes) to the query so that I can use the orderby argument. I know the ID of the page I need to add. How ...
0
votes
1answer
33 views

Inner join overrides Advanced Custom Fields plugin's get_field [closed]

I have this search that I made with inner join and where clause. I no longer get get_field() values, they all return false. How can I get ACF to work again? It must be something silly that I don't ...
0
votes
1answer
70 views

How to add div blocks after certain set of post

Ok I broke my post down into different style settings. Like shown below. The first post is a large block. the next four post are small and aligned next to the larger post. I used the loop below to ...
0
votes
0answers
16 views

MySQL query in Functions.php using inner join to override/add to search

I'm setting up a radial geo-location search. I have users select a zipcode and a radius to search within. I want to use the regular search site.com?/s=abcd&zipcode=90210&radius=10 I look up ...
-1
votes
0answers
9 views

Query custom post type by taxonomy without running the whole custom post type

This query that I have show all the posts that I have in my books custom post type: <?php query_posts('post_type=books&showposts=-1&order=DESC');?> <?php while (have_posts()) : ...
0
votes
1answer
36 views

Hide text if query has no posts

I'm using a custom query to display events CPT inside another CPT. The given query has a section title, which I don't know how to hide when there are no events. I've tryed to include the section ...
0
votes
2answers
39 views

Problem in exploding the_content to array

I've written a code in a WP_Query to converting a string (the_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. ...
0
votes
1answer
30 views

Create custom query for search?

I have create search box using ajax.If i enter any value in search input box that this value search in post title or post meta data and get all data of this value in custom post type.also query check ...
0
votes
1answer
29 views

Empty tax_query array returns an empty array

I would like to return all posts when the tax_query['terms'] is empty. $args = array( 'post_type' => 'product', 'posts_per_page' => 15, 'paged' => $paged, ...
0
votes
1answer
46 views

Get the post permalink within the loop but without additional DB query

I am looking to create a custom 'directory' page which will link to several thousands of posts. Because of the large number I am trying to limit the number of DB queries. I notice that to link to each ...
0
votes
1answer
26 views

Advanced Custom Fields Query with Different Values of the Same Key

I have a custom post type set up with Advanced Custom Fields. I would like to display and order my posts in groups. The groups are states of the United States, so I have 50 groups. Should I perform ...
0
votes
2answers
21 views

Where and when does WordPress invoke routes

One of my URLs for which I'm wanting to create a Category Archive is coming up with a 404 despite having matching routes and, supposedly, matching templates. I'm going through the core WordPress code ...
0
votes
0answers
10 views

No results for taxonomy archive page

So, I'm making a taxonomy template page for a plugin, but I'm not getting any results from my query. I'm loading the template with this. function projects_categories( $taxonomy_template ) { if( ...
0
votes
1answer
20 views

meta_value timestamp older than now

In my wp_posts table I want to select the rows where post_type == event. I also want to a connection with wp_postmeta from the specific row. In my wp_postmeta table I want to do a where like this: ...
0
votes
0answers
12 views

WP Query for newest post of each taxonomie of a custom post type

I'm trying and googleing since 2 days, but cant figure out how I can display my 8 needed posts. Details about my structure: I'v created an custom post type "projects" where all the posts about ...
0
votes
1answer
58 views

How to show posts rank based on custom field value

I have total 100 posts, 10 posts in each page on homepage with paginatin. Here is my code $args = [ 'posts_per_page' => 100, 'fields' => 'ids', // Add additional args here ]; ...
0
votes
0answers
13 views

Get adjacent post data, ordering by custom field values (by Wp-query?)

I want to build a custom version of the adjacent-function of wordpress post. I have two custom field values for each post, my layout is the following: metafield1 value 1 & metafield2 value 1 | ...
1
vote
3answers
90 views

Limit number of pages in pagination

I have more then 500 posts and I want to limit only 100 posts with pagination. So, 10 pages with 10 posts in each. Here is my code. $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ...
0
votes
0answers
16 views

Add a banner image after first post, across the WordPress website [duplicate]

I am looking for a way to add a banner image after first post across the website. If it was about adding a banner on one page only, homepage or category page, then I could have done this in WordPress ...
0
votes
0answers
15 views

How can I take input from a form, run it through a custom query, and display the results?

I'm having a good bit of trouble here. I'm working on a plugin that should be able to, among other things, allow the use of a shortcode to search through custom post types and their custom fields. I ...
0
votes
1answer
57 views

Ascending & descending posts on same page with IF statement

I need to be able to display a list of events on 1 page. The top list would be for upcoming events and to be sorted with earliest event first and the second list would be for expired/past events and ...