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

learn more… | top users | synonyms

1
vote
1answer
21 views

Alter a specific query on Wordpress

I need to change a query of a plugin that is not the main query. The author did not put any filters. I can see the query from $wpdb->queries Is there a way to access the specific query and ...
0
votes
2answers
21 views

Querying with WP query using meta key price

Could somebody tell me what's wrong with my WP query please? I'm trying to order my posts by price and price is an ACF (a textbox which has a number in it) $args = array ( ...
0
votes
1answer
26 views

Pagination is not working on custom query inside a custom home page template

I know this is a duplicate question. But to comment on existing question, I dont have enough points. So here we go.... Pagination is not working on custom query inside a custom home page template. ...
0
votes
1answer
29 views

How to pull posts into two columns with different image sizes using $counter variable?

I have a custom module pulling one specific category with 6 posts displaying the featured image into 2 columns. I like the first article of the top of each column to display a large image as shown in ...
2
votes
1answer
127 views

If No Search Results, Show Posts from Alternate Search Query

I have a pretty standard loop which outputs "Sorry, No Posts Found" when a search result comes up empty. if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( ...
0
votes
0answers
26 views

$post breaking container loop

Problem I have a foreach loop grabbing posts inside an advanced custom fields repeater. When it's finished looping through posts it breaks the repeater. I believe the problem is with $post as far as ...
0
votes
0answers
16 views

How to display near by post using latitude & longitude and The Haversine formula

I have a Custom Post Type called "events" that has Advanced Custom Fields "latitude" and "longitude". I'm trying to display all "events" within 75 miles of the user. This is what I have so far: ...
0
votes
0answers
22 views

Popular posts from 7 days loop

I'm trying to create a "loop" which will display Popular Post from a week or any other timeframe. What's the best way of doing it? Also, is it possible to order the posts by views? EDIT: Here is ...
1
vote
1answer
28 views

No results found from a $wpdb->get_results() query when trying to join more than one meta key query

That title was a real mouthful. I have a custom post type called work with three custom taxonomies called work-client, work-type, and work-service. I'm using Advanced Custom Fields to make a nice ...
0
votes
2answers
28 views

Function to limit number of custom post types on homepage - TwentyTen

here is the deal... I got hold of this piece of code to change the default post type shown on my TwentyTen child theme's homepage. It works like a charm when I add this code to the functions.php ...
0
votes
1answer
26 views

shorthand syntax for custom fields

I'm trying to write a shortcode and am sorely out of practice with this stuff. It's for a plugin Full Width Audio Player and I'm trying to query all tracks within a certain playlist so it will output ...
0
votes
0answers
14 views

run search / query from multiple databases

First of I would like to warn everyone, that my skills set in mysql and php is novice. My current wordpress website is based on a network setup (mutli-site), with the help of shardb, I was able to ...
0
votes
0answers
12 views

Compare datetime

I have a query to fetch all the posts that have status: publish and post_date <> post_modified. Query: select id, post_title, post_date, post_modified from wp_posts where post_type='post' and ...
0
votes
2answers
25 views

Custom Wordpress Table wpdb

running into issues querying a custom table and getting results. As of Wordpress 3.9, I can no longer run mysql_query(), and have to use $wpdb->query(); So keeping that in mind: Old Code: <?php ...
0
votes
0answers
23 views

Function to bypass specific words in search?

Is it possible for a word to be skipped/excluded/ignored in the default search? For example if I could make it so that if I type the great thing in the url instead of '?s=the+great+thing' it will ...
0
votes
1answer
75 views

Loop through multiple custom fields with increasing number

I have a problem with custom fields that I have been trying to figure out for a while, but with no luck. I have a section on the site I'm building that let's the users publish content form the the ...
-4
votes
1answer
44 views

WooCommerce Total # orders [closed]

total number (#) of orders, maybe create the function in functions.php and call it in a shortcode anywhere in page. I just don't want to update it.
-4
votes
0answers
16 views

Get WooCommerce Total Products # [duplicate]

How can I just get the total number (#) of products, maybe create the function in functions.php and call it in a shortcode anywhere in page. I just don't want to update it.
0
votes
0answers
37 views

Dynamically load content based on Title and Category

After googling for about 2 days now without finding the proper answer - and I must commit that I'm not that well educated in php programming, I hope the community may provide me with the correct ...
0
votes
1answer
20 views

Query pages by child term

I cannot seem to get this to work, I have tried everything I can think of and spent enough time googling, to get me to seek help elsewhere. I need to query pages in a loop, using the same taxonomy as ...
0
votes
1answer
27 views

How do I create Comma Separated list of attached image ids?

I'm trying to grab the image id's of attached images to a post. I'm using an example posted here, but am having trouble returning the just the ids and not the entire array. My goal is to return a ...
0
votes
1answer
30 views

WP Query Sort by meta value (date)

I have the following code where I want to sort by meta key "event_date" and only display posts after todays date and 3 weeks ahead. Somehow nothing happens, even when I'm stripping down the WP Query ...
1
vote
2answers
57 views

Meta Query relation “AND” then set array accordingly

I have a search form on my home page that sets up the url query_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results ...
0
votes
1answer
24 views

Wrap/close 'query' for a first-letter ordered listing of posts

Sorry for the title, I didn’t know how to call it better. I am working on a site on which I am building a listing of doctors being ordered alphabetically by last name/word of title, while all posts ...
4
votes
1answer
70 views

What is the most efficient way of querying posts based on visits and date for current day?

I am about to develop a piece of code for my site to display the most popular posts of the day that are X days old. I would like some help from you to achieve this the most efficient way. This is ...
0
votes
0answers
29 views

Using wordpress with AJAX queries

I have built a custom theme for wordpress and I decided to use AJAX instead of just refreshing the page on each call. However, when I add the Wordpress loop to call in my data, it doesn't load at all, ...
0
votes
0answers
29 views

Sort by meta_key

I want to sort products by height, but some of my products like accessories don't contain height section and they're automatically disappear when I sort by height. Is it possible to sort by height ...
0
votes
2answers
25 views

Several taxonomy query (like filter)

I have a problem with making something like taxonomy filter. My code is similar to this: $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( ...
0
votes
1answer
27 views

How to get a query odered by N of matching taxonomies?

How can I get a wp query that is sorted by how many tags (in my case) match a specified list? I want to retrieve a list of posts that match the category of the current post (which is a plain filter) ...
9
votes
1answer
107 views

Should we trust the post globals

@toscho left a comment to this answer which had me thinking again. How much trust should he have in the global scope, specially regarding the post globals like $post. So what? The global variable ...
1
vote
1answer
24 views

Custom query to get terms from post ids

I want to get the terms object by given posts ids. I don't know much about sql, and this kinda complicated for me. Here is what i tried: global $wpdb; $taxonomy = 'category' $term= ...
0
votes
0answers
23 views

Using offset with custom Archive page

Situation: News page - Currently shows the latest 5 news items Archive page - Starts on post 6, I've setup pagination. For testing purposes I've got 20 posts numbered 1 - 20. <?php ...
0
votes
0answers
22 views

Passing key to add_query_arg function

This is my edit link in template file $edit_link=add_query_arg( 'ser_edit', $post_id, $edit_link ) ; This is my html code. <a href="<?php print $edit_link;?>"><?php ...
0
votes
1answer
25 views

Advanced Post Display/Pagination/Ordering

I am working on a project that requires some advanced ordering of posts and advanced pagination. Basically, we have posts in a category, lets call this category 'mycategory'. We then have post ...
0
votes
1answer
49 views

Custom Post type is being ignored in query

I have a custom post type called "results" and on my single results page I want to perform a second query after the main loop. The second query is as follows: $myquery = new WP_Query(array( ...
1
vote
1answer
37 views

How to retrieve elements from another table in a SQL query?

I get data from a table wp_posts and now I need to get data from the table wp_postmeta that match the ID captured in wp_posts table . The data that I need to grab in the table wp_postmeta are ...
2
votes
2answers
126 views

How to order WP_User_Query results to match the order of an array of user IDs?

I'm using WP_User_Query to get a list of users from my database. I'm showing specific users only via use of the include parameter. For example: $args = array( 'include' => array( 1, 3, 5, 99, ...
0
votes
1answer
109 views

Order by meta value pro first then meta value free in my search function

My meta key is geo_listing_type and this key have 2 meta_value, pro and free. I want to order these by pro first then free <?php get_header(); ?> <!--Start Content Wrapper--> <div ...
0
votes
1answer
30 views

How to sort results from a custom database table

I've created a custom WordPress database table which I'm using to store 'likes'. The columns I have are: id post_id user_id I'm now trying to get an array of post IDs that a particular user has ...
0
votes
3answers
47 views

Re-sort get_posts query results

I have a query that pulls fields from the 3 most recent posts for a carousel: get_posts('posts_per_page=3') I need to re-order the results so that instead of it being 1, 2, 3 it is 3, ...
3
votes
2answers
109 views

How to Optimize WP site for millions of posts

I'm working on a website for a company that will very likely be creating millions of posts via a custom post type. They're prayers, so basically the user on the front end just submits a short phrase ...
3
votes
2answers
109 views

How to search display_name column when using WP_User_Query

I'm using WP_User_Query to bring back a list of users. According to this article, I can focus the query on particular columns (I'm assuming in the wp_users table) using the search_columns param. My ...
0
votes
1answer
35 views

Brainstorm - Slow Query from Plugin Need to Speed It Up

We use WP as the backend for a business directory. I have a plugin that queries based upon location coordinates looking for the closest 10 locations to a given "listing". This query is really slow ...
3
votes
2answers
100 views

Differences between wpdb->get_results() and wpdb->query()

Who can explain me the differences between wpdb->get_results() and wpdb->query() in making generic queries to wordpress db?
-1
votes
1answer
24 views

Print data from wordpress sql query

global $wpdb; $video = $wpdb->get_results("SELECT * FROM wp_video"); $video has no value when do echo, and when I do print_r($video), it has a value print_r($video) = Array ( [0] => stdClass ...
0
votes
2answers
47 views

Combine privileged users array with my current query

I have a custom page template with the following query. Isotope filers my categories and all this works fine. I want now to make this page only viewable by a few specific, currently logged in ...
0
votes
0answers
70 views

Ordering posts alphabetically by meta keys and title

I have a query for custom posts and I have managed to order the results alphabetically based on the title first then a 2nd alphabetical ordering of the 1st of 2 meta keys "Species". This works great. ...
3
votes
2answers
136 views

Query by one meta_key and sort by another (possibly NULL value)

I want to query by 1 meta key, but sort by another key that may or may not exist, and then by post date So the end result would be something like: Meta Key A / Date 1 Meta Key A / Date 2 Meta Key B ...
0
votes
1answer
54 views

Pagination in custom query in a category page

In a category (I create category-123.php), I'd like to create a new custom query in order to show all the posts that have right parameters (custom fields). <?php $today = date("Ymd"); $paged = ...
-1
votes
2answers
23 views

how to query multiple categories in wordpress?

I am trying to query multiple category in wordpress but no luck, I don’t see anything wrong with my code. Herewith my code below : query_posts('posts_per_page=1&cat=5,1'); while ...