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

learn more… | top users | synonyms

2
votes
1answer
85 views

Filter Media Library by author or post_parent

I am trying to filter the Media Library so only media items that are uploaded by the current user OR children of the post being edited are visible. I've had no problem doing it if the conditions are ...
0
votes
1answer
119 views

post__in not working with pre_get_posts, but post__not_in does work

I have an action setup on pre_get_posts which I would like to use post__in on. I used the following code as a test: $query->set('post__not_in', array(74485,1528,71460)); This works, the total ...
0
votes
2answers
52 views

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => ASC )); All ...
0
votes
1answer
24 views

how to insert missing tags into the posts through mySQL?

I am looking for a SQL query to insert a tag to multiple posts from a specific category. A pseudo query looks something like this: INSERT INTO POSTS VALUES TAG = "tagName" where Posts ...
-1
votes
2answers
84 views

show all custom posts types in home page

Hi i am working on custom post types in wordpress presently we are using below code to display the custom posts, but the thing is the custom post types are keep on increasing, add_action( ...
0
votes
1answer
36 views

Apply ordering args to newly merged queried

I have two queries with arguments and then I merged them to form my new query - $wp_query. I would like to now apply arguments to the new query to show the merged pages/posts by meta_value_num. This ...
0
votes
0answers
53 views

How to organize a WP_Query's list of posts by category and display category title?

If I run a query with some args and get a list of posts, how can I organize the posts separated by category and display the title of each category? $array_out = array(); $args = array( 'orderby' ...
0
votes
0answers
35 views

Can I use multi (sub) levels of relation (AND | OR) on custom query?

I'm tryng to do the equivalent of: $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'OR', array( 'relation' => 'AND', ...
0
votes
2answers
101 views

How many Wordpress SQL Queries per page?

I am on a shared hosting which has a limitation at MySQL queries per hour. My shows unable to connect to database because of this. Can anyone tell me how many queries are per page on a wordpress site ...
0
votes
0answers
33 views

Get a list of the last posts grouped by author and filtered by category

i need a list of the latest post published by various authors, but filtered by category, like for example the latest posts of author that write about music. i wrote this query and looks like working ...
0
votes
0answers
44 views

Can I query another data table on a multisite with the single.php template?

Here's a quote from a thread on this forum showing exactly what I'm trying to do: blog 1 gets = wp_post table blog 2 gets = wp_2_post table Small multisite setup, two very different sites, both ...
0
votes
1answer
82 views

WordPress SQL query to tag all posts containing a specific word on title

Is there a way to bulk tag all posts which have for instance "bottle" in their titles? Thanks!
0
votes
0answers
22 views

Tax Query not working

I'm having some trouble with my tax query. Im getting some values by GET, but it seems my tax query refuses to work: $args = array( 'post_type' => 'imovel', ...
0
votes
1answer
268 views

Custom post type posts don't show in archive widget

I have a custom post type called 'Podcasts' but none of the posts are showing in the archive widget. Only the main query (blog posts) are being shown. I've tried adding this code below to include the ...
0
votes
0answers
153 views

SQL query for converting post meta image url to featured image

WordPress guru, we have a question: We work on a website, which was not updated a while. Most of time it have wordpress 3.2 installed. We've updated it to the latest wordpress version, but ...
0
votes
1answer
55 views

Match two taxonomies to display a specific content

I have a page divided in two bars. The left bar is a side menu, which shows contents for a specific country (ie: if I am in the Mexico page, there are options listing Cancun, Acapulco, Mexico ...
0
votes
1answer
37 views

The use of including upgrade.php when building custom queries

I started building a plugin in which I need to build some custom queries with wpdb object. It's the first time I use it. So I checked out how to use it. I watched some examples and there is something ...
0
votes
0answers
43 views

Search form not working on page templates

I have this on my searchform.php: <div class="search searchform" role="search" method="get" id="searchform" action="<?php echo home_url(); ?>"> <form action="#"> ...
0
votes
1answer
43 views

Query only the posts with a post format of “audio”

I'm trying to query only the posts that have a post format of audio. I'm pretty sure I'm doing this wrong. Can I get a little help? <?php get_header();?> <section id="content"> ...
0
votes
1answer
31 views

search.php is not generating the right results

I have a situation that didn't happen before. My search.php file didn't generate results, it just loop through all posts although the url is correct Domain_name/?s=key Here is the searchform.php ...
0
votes
1answer
51 views

Modify users.php query with multiple taxonomies

I've successfully created 3 taxonomies attached to the user object, using the registered_taxonomy and update_count functions of this code - ...
0
votes
2answers
129 views

mySQL queries are executed twice on wordpress website

I'm sorry for my english. I'm trying to add some functionalities at my Wordpress website and to do this i have added a function in my function.php theme. The idea is to save in a custom table some ...
0
votes
1answer
27 views

How do I get all results from my query

I have written some php code and using the class.pagination.php, am able to paginate it based on a max posts per page that I set inside my code. This works great. However, it is only returning 11 ...
1
vote
0answers
111 views

WP_Query orderby and tax_query

My goal is to have custom posts type's posts (CPT for simplicity) from a custom taxonomy (CT for simplicity) let say CT Hometown with slug Nebraska to be listed grouped by another CT, let say ...
0
votes
0answers
23 views

Meta query not working with pre_get_posts

This works $q->set('meta_key', 'available-date_%_from'); $q->set('meta_value', '20140701'); This doesn't $q->set( 'meta_query', array( array( 'key' => 'available-date_%_from', ...
0
votes
1answer
32 views

excludeCat function reverses order of blog posts

I'm using the code below to remove category #5377 from the query on the home page. However, this code is also reversing the order of blog posts for some reason. How can I alter this code to only ...
0
votes
1answer
22 views

Grab next post title in archive page

I am using a custom query on a page to display single posts from a specific category, one post per page. Here is my current query: $results = new WP_Query( array( 'post_type' => 'post', ...
0
votes
2answers
43 views

Sort order in get_posts [closed]

I've created a custom template for a client. This is going to be a multilingual site setup on a Multisite install. As you can see under each category letter, the posts start out in alphabetical order ...
1
vote
1answer
36 views

How to get a query variable?

I have added a query variable with the following function: function add_my_query_var() { global $wp; $wp->add_query_var('myvar1'); } add_filter('init', 'add_my_query_var'); Now on a ...
0
votes
0answers
35 views

add_query_vars does not work

I have added this code in the TwentyFourteen theme's functions.php file. function add_query_vars($aVars) { $aVars[] = "msds_pif_cat"; return $aVars; } add_filter('query_vars', ...
0
votes
1answer
82 views

WP_User_Query with more than two custom meta values

I am trying to create a custom user query based on users' metadata. I have the following query created. $users = new WP_User_Query( array( 'search' => '*' . $search_name . '*', ...
0
votes
0answers
17 views

Build query from the url given

I have an ajax request coming with parameter called "next_page_url" => "URL_FOR_THE_NEXT_SET_OF_POSTS" Now I need to build a WP_Query arguments using that url to respond to that AJAX request with ...
1
vote
1answer
182 views

Create Pop-Up Box with Custom Field Content Inside the Loop

I tried this using ThickBox first, then tried using some code I had that worked on another website... Total failure. The Goal: I have a custom post type (product) with a ton of custom fields. I also ...
0
votes
1answer
29 views

Query unique author ids with published post of type job

I'm trying to come up with a simple query to return an array of unique author IDs that have a post_status of 'publish' and a post_type of 'job'. I know I can query using: $args = array( 'post_type' ...
0
votes
1answer
82 views

Retrieve posts by term id custom query

i want to retrieve custom posts using using custom query . my taxonomy is recipe_tx and terms (Beef) , (Chicken) etc in it . i have tried using SELECT p.* FROM wp_posts p, wp_term_taxonomy tt, ...
0
votes
1answer
338 views

wpdb::prepare was called incorrectly

I have this code to remove orphaned posts after deleting custom post type. It works, but this code... global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE a,b,c FROM wp_posts a ...
0
votes
0answers
56 views

How to filter the terms to a special custom taxonomy?

I do have a custom taxonomy called "countries". With the code below I get for each term (country) the number of its published posts in brackets, like the following: Canada (3) USA (5) Italy (2) ...
4
votes
1answer
131 views

How to uniquely identify queries?

Today I was thinking about how to differentiate queries, mainly to create an unique identifier. In the process I played around a bit, see below code. The main idea is to do it depending on the ...
0
votes
0answers
54 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
1answer
48 views

Is MySQL query cache useful for WordPress?

Starting from MySQL 5.6, if you use InnoDB as the default engine, the query cache is now officially disabled. We've a quite moderate traffic WordPress site and experience a major downtime when we ...
0
votes
1answer
40 views

Slow query when joining wp_posts with a lookup-table?

I'm developing a map-based website and need to get posts associated with a place. Each place has a post in wp_posts and the other associated posts (images of each place etc) is associated with the ...
0
votes
1answer
27 views

Pulling values from a sepcific row in table

I'm trying to get the first and last name values for ONE person in a database where the meet certain conditions of being a team leader and having a specific project id. Because of this, it will always ...
0
votes
1answer
51 views

Need help setting up a search form for wordpress [duplicate]

I want to set up a search function as a widget in wordpress. This is the situation that I have. 1- I have 3 custom post types 1.a: Each post type has custom fields and taxonomies. I have regular ...
0
votes
0answers
73 views

Get the menu name or location of current menu item

I am having a hard time trying to get the name of the active menu and, apparently, I cannot find any solutions to this issue. Basically, I have several menus that follow this pattern: Menu Name ...
0
votes
0answers
49 views

Show posts with specific tag in a category page

I have a website which belongs to a magazine. I want do something like this: I want to create a link that refers to /category-slug/tag-slug. in that link, I want to show all posts with "specific tag" ...
0
votes
0answers
33 views

A pagination-sort-of-thing on single.php view for the custom post type

First, a quick demonstration of what I need to achieve: It would work similarly to <?php previous_post(); ?> and <?php next_post(); ?>, but also include an actual "reel" indexing all ...
0
votes
1answer
57 views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
0
votes
0answers
17 views

How to cancel a custom post type query based on existing cache file

Is there a proper way to greatly restrict the query (or remove it altogether) for a custom post type type-single.php file? Simply stated, for reasons of speed speed speed I've cached all relevant ...
0
votes
1answer
22 views

Removing a post from the results of a WP Query

We have a complicated database query and we would like to exclude some posts. We've tried to do it with SQL, but it's really complicated. The simplest solution seems to loop through the results after ...
0
votes
1answer
59 views

Sorting posts according to view counts not working

I use the code snippet below to get views count of each post on my sidebar.php . everything works but the sorting does not. also it does not get 4 posts, it only shows 1 post although I've written ...