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

learn more… | top users | synonyms

2
votes
1answer
389 views

Custom Post Type order by modified date and custom meta field issue

I'm creating a plugin with some kind of offers that users can publish. User, in his custom administration panel, can managed his own offers. Offers are free and premium. If offer is premium it take ...
0
votes
0answers
16 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
2answers
541 views

How to exclude custom fields from search queries?

I'm building a hotel search engine and I've first created a custom content type "hotel" with Types & Views Toolset. I'm using "Search everything" plugin to query custom fields and custom taxonomy ...
1
vote
1answer
460 views

How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently ...
0
votes
1answer
16 views

How to make an insert in wp_posts and use the data inside of WordPress?

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
2answers
681 views

Custom MySQL Query for Post and Post Meta

I have a custom table called "tags" that contains a charity_id that is a reference to a post ID ... I need to query the "tags" table to grab this charity_id and then pull in the post title and a few ...
0
votes
1answer
14 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 ...
3
votes
1answer
787 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
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 ...
2
votes
2answers
2k views

Get category slug and display it on a query_post

I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories . there is two parts to my question - Part A - Get category slug and ...
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
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
3answers
1k views

How to delete all posts, categories and tags from Wordpress database

I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this ...
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
0answers
19 views

Why isn't my featured post being picked up? [closed]

We had a company create us a WordPress theme and they have added in some features to get the blog working exactly as we want. One feature is to have 3 featured articles at the top of our "magazine" ...
0
votes
1answer
491 views

Random Category with Recent Post Title and Thumbnail

This code below works perfect to pull the title of five random categories, the issue is for each random category I want the latest post title and thumbnail but where and how do I add the post query? ...
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 ...
1
vote
2answers
589 views

Sticky post appears twice

I am trying to modify the number of posts_per_page in the loop. This way: function posts_per_page($query) { $query->query_vars['posts_per_page'] = 3; } add_filter('pre_get_posts', ...
0
votes
1answer
644 views

Load more posts with multiple queries

I've been developing a theme which uses the load more ajax plugin, everything is setup and working great with the main query. But, once I setup a new query for popular posts, the load more posts ...
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
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

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
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
1answer
20 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
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
53 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
2answers
419 views

Get ID of child from child slug, while knowing parent ID

I have a hierarchy that I need to get data from. It's the child (by slug name) that I need to get while already having knowledge of the parents. Highest Known Parent Page (slug : 'parent') |_ Child 1 ...
0
votes
1answer
982 views

Retrieve and display data from custom db table in admin area?

So, i'm having a bit of an issue with a plugin i'm developing, I wonder if anyone can shed any light on the situation, as many, MANY searches have come back with zero help. :-/ Basically, my plugin ...
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" ...
1
vote
1answer
550 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
0
votes
1answer
32 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
18 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
63 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
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
1answer
505 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
0answers
10 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
17 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
381 views

Query set using tax_query with relation 'OR' modifies category object?

(Update: Please see the edits far below.) The code: function itsme_better_editions( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ...
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
35 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. ...