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

learn more… | top users | synonyms

0
votes
1answer
23 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
26 views

WooCommerce Total # orders

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
15 views

Get WooCommerce Total Products #

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
23 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
16 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
16 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
19 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
1answer
39 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
21 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 ...
3
votes
1answer
51 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
21 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
27 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
23 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
26 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) ...
-4
votes
0answers
16 views

how to get subcategory with related post

i want when click a category in index,print subcategory with related post like (w3schools) in category but do not know do this, please help me.
6
votes
1answer
88 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 ...
0
votes
1answer
13 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
18 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
9 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
22 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
39 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
34 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
105 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
98 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
24 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 ...
-4
votes
0answers
21 views

Get posts order by meta key and meta value [duplicate]

For getting posts order by meta key and its value use following code. $args = array( 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'moments_in_history', ...
0
votes
3answers
43 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
92 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 ...
2
votes
2answers
76 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
28 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 ...
2
votes
2answers
78 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
21 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
40 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
51 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
124 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
44 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
22 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 ...
0
votes
0answers
32 views

Import SQL tables from SQL file on plugin install

I'm building a plugin, on installation of the plugin it needs to create several tables. Now I found out that I can do that in the plugin code sorta like this.. // Function to create new database ...
1
vote
1answer
43 views

List all posts from past week grouped by sub-category

On a category specific template, I want to list all the posts from the last 7 seven days for that single single category and group them by subcategory. This is the code I have so far, which lists the ...
0
votes
2answers
75 views

How to get my loop to pull posts into three columns

I have my page template pulling one specific category & pulling the featured image & title into 3 different columns on my site. The problem is they all pull the CSS class .proj-left how can I ...
0
votes
2answers
18 views

Do not show children of a category

I'm trying the next code: $categoria = get_the_category(); $hijosCategoria = (array) get_term_children($categoria[0]->term_id, 'category'); $queryBase = ...
0
votes
1answer
16 views

Update vs Insert logic but the last key is always inserted?

I have added a custom db table which looks like usermeta table, just storing some key - value pairs. But now i am stuck with the following logic a/ if key exist for a user use an update query else ...
0
votes
0answers
66 views

Get post ID and custom taxonomy of posts that belongs to certain category, efficient by SQL?

I have a large Wordpress site with almost 200 000 "posts" (everyday is aded more than 2000 new) and sppecific homepage with about 30 loops to get last 5 posts from every category (sngle loop = single ...
0
votes
0answers
59 views

Custom query to update user meta data (also with a custom table)?

I have add a custom table (wp_shopping_metavalues) to the WP install which looks like wp_usermeta. I am displaying user values from both tables. For the insert i use function ...
0
votes
1answer
40 views

Query Custom Post Type posts by Keyword/url slug

I am running an affiliate shop with around 10k products and I am trying to build Landingpages for SEO/SEM purposes. Those pages should contain a title, some text and related products. I would like ...
1
vote
1answer
20 views

Custom Field Create Bulk via SQL Query

I have a question. A created a custom field named video_desc. I have ofer 2000 posts and I need to add this custom field to all posts and add the text "Description Here" to it. How can this be done ...
0
votes
2answers
87 views

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = ...
-1
votes
1answer
38 views

wpdb query with dynamic column name?

How can i dynamically set a column name in $wpdb query? i tried $which_column = 'phone'; $data_check = $wpdb->get_var("SELECT '.$which_column.' FROM wp_shopping_preferences WHERE wp_user_id = ...
0
votes
0answers
26 views

What's going on with the get_pages() 'number' argument?

According to the codex, the get_pages() 'number' argument works the same as an SQL LIMIT. number (integer) Sets the number of Pages to list. This causes the SQL LIMIT value to be defined. ...
0
votes
0answers
18 views

Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?

I have the following problem with featured tag posts I have a page of a website in wich I want to show only the posts that have setted a specific tag (using the loop). So in this page I have put ...