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

learn more… | top users | synonyms

2
votes
2answers
47 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
17 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 ...
-2
votes
0answers
12 views

hey!!! am developing a one page wordpress theme and I need help with the code to pull in specific page content using pagename [closed]

this is not working for me 'page-1'); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : ...
0
votes
0answers
16 views

URL Friendly for parameter in URL

I have created a rewrite rule for a custom parameter using this code: <?php function add_query_vars($vars) { $vars[] = "cid"; // represents the clinic id return $vars; ...
0
votes
2answers
32 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
30 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
104 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
30 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
17 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
19 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
37 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
46 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
13 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
36 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
33 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
30 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
16 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
64 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
29 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
22 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
16 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 ...
0
votes
0answers
13 views

Why I have this strange behavior when I try to exlude the featured post from posts visualization?

I am quite new to WordPress theme development and I have a strange behavior with this custom theme on which I am working: http://lnx.asper-eritrea.com/ As you can see in the home page I have 2 areas ...
0
votes
1answer
34 views

Advanced SELECT query with condtional statements

I am having trouble understanding the proper way to write an advanced select query. I have the following the code here. if (!empty($_GET['3321body_type'])) { $bt = $_GET['3321body_type']; ...
1
vote
1answer
72 views

How to get the posts published in last two days using WP_Query?

I am trying to loop through all the post to get the top most shared posts on social network. I want to use the date_query parameter in the WP_query to get the posts of last two days , last 5 days, ...
0
votes
1answer
34 views

Next 10 posts data of currently viewing post in blog page

I am developing a theme and using WP_Query to fetch the content from the database, but now i wanted to implement a loop using a WP_query that will show me the next 10 posts with title links and ...
1
vote
2answers
55 views

Select Multiple meta_value from WP DB; Single Query

I am trying to retrieve each user's first and last name, phone, email, and address from the usermeta table. I'm having trouble selecting multiple meta_values, each with its own meta_key, using a ...
1
vote
2answers
41 views

Transient not working for custom loops

I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of ...
0
votes
0answers
18 views

Archive query not working correctly

I think I am missing something while trying to create an archive page for my post type I decided to put three levels of data in one post type and was going to separate it by templates depending on ...
0
votes
0answers
30 views

trying to update post meta in bulk

I have been trying to arrange my site so that my URL structure is set to domain.com/collection/%collection%/%product-group% Where %collection% is a taxonomy term, collection is the index, and ...
0
votes
0answers
48 views

Unserializeing multiple column values that are stored in one database results variable

Lately i have created a custom template to search for data in a database, and also displaying it, by the use of checkboxes. So, a user can select multiple checkboxes to search data on and the query ...
0
votes
0answers
47 views

How to group by custom posts by child taxonomy term

I have registered a custom post types named "property" , a custom taxonomy "city" is associated with that post type . I have couple of city like Ontario Toronto street 1 street 2 ...
-1
votes
3answers
39 views

WP Query outputs three items within a div

At present I have a basic query that outputs 12 custom posts, each in a div. I need to restructure this to output four divs, each with three of these items inside. So it's sort of like a nested div. ...
0
votes
2answers
72 views

Determing number the query ran by core wordpress

I wanted to find out, how many queries does wordpress core run, and how many queries the theme run. Is there any way to get they number of both of them separately ? As i run `echo get_num_queries(); ...
0
votes
1answer
31 views

How to overwrite orderby with add_query_var

So I would like to have an archive that displays its posts in a random order. <?php $query = new WP_Query($query_string."&orderby=rand"); ?> But also then if the user chooses they ...
0
votes
1answer
30 views

How do you display the number of a post in a query?

I want to display the number of a post beside each post title in a query, such that it literally appears like this: Post title one in query Post title two in query Post title three in query How do ...
-1
votes
2answers
49 views

Query: offset post list, unless it's a specific category

Here's my code: <?php query_posts(array ('showposts' => '1', 'cat' => '-11')); if (have_posts()) : while (have_posts()) : the_post(); get_template_part( 'content', 'archives' ); ...
0
votes
1answer
102 views

Advanced Custom Fields - Relationship post foreach query

I've created a post type, called Package (for news packages), and want to be able to link to specific blog posts and display them on the single-package.php page. I'm using ACF relationship fields, and ...
3
votes
1answer
38 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
0
votes
1answer
76 views

Can't update multiple rows with $wpdb query

it seems that I cannot update multiple rows to change the post_type of posts having a specific tag. I follow different method, even if it seems the good one is this one : global $wpdb; $result = ...
0
votes
0answers
15 views

Incorporating a meta query into a mysql query in wordpress

I'm trying to find a way of inserting a meta condition into this bit of SQL below... $query = "SELECT COUNT( ID ) as num_events " . "FROM $wpdb->posts " . "WHERE ...
0
votes
1answer
49 views

Only show upcoming event or current events

I've been working on this website event page http://aishaarab.com/events/ everything is working but I have 2 problems: I can't get it to only show upcoming event meaning when an event is ...
-1
votes
2answers
42 views

What's wrong with my $wpdb prepare

I can't get my head around this. I get this error: Parse error: syntax error, unexpected '"' in 224. The line is this between foreach $html: $html = ''; foreach ( $recent_across_network as $post ...
0
votes
1answer
83 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
2answers
42 views

Why in this archive page that call query_posts() function show only the last 10 posts?

I am pretty new in WordPress theme development and I am finding 2 problem with this posts archive page: http://lnx.asper-eritrea.com/archivio/ The previous page have to show ALL the blog posts into ...
0
votes
1answer
19 views

How to get link and title of next and previous post on single page

Guys How can I get the link and title of both next and previous post on the single page? Just like in the screenshot below. I try to use this but nothing shows up. $prev = get_previous_post(); ...
0
votes
0answers
36 views

Horizontally paginate through sets of blog posts?

I have my posts set up like this: I would like users to scroll through the posts using the left and right arrows. So when users click on the right arrow, for example, the next six posts would slide ...
0
votes
1answer
39 views

Some doubts about how the loop work (trying debugging it)

I am very new in WordPress development (and also in PHP development, I came from Java and C#). Today I have installed Aptana and configured XDebug to inspect what happens into the TwentyTwelve theme. ...
0
votes
0answers
28 views

Title outside of the loop in page template

I have a page template, with a very simple default query. The problem is that the title is outside of the loop, because of the layout. What do you think, is it problem? Or do you know an other way? ...
0
votes
0answers
51 views

Problem with correctly registering query variable

I have an admin page for my plugin, which lists records from database. I want to sort them under some conditions. To call different sorting options, I've decided to use query string. Step 1: At ...