The wpdb class, accessed via the $wpdb global variable, is used to interact with the WordPress database
0
votes
1answer
79 views
Why doesn't my Table get created?
I am working on creating a table in the DB for a plugin but cannot figure out why the table is not being created.
Here's my code:
global $ds_swoons_db_version;
$ds_swoons_db_version = '1.0';
...
0
votes
2answers
705 views
How do I modify this wpdb query to include posts that have a post_status of publish and draft?
I'm using the following function to count the number of posts an author has made from a custom post type.
<?php
function count_user_posts_by_type($userid, $post_type) {
global $wpdb;
...
0
votes
2answers
147 views
How to query and update one colum in postmeta table?
I'm trying to make a popularity calculation for all posts, based on page view and date of creation. Initially, there's a default popularity value saved in postmeta. Every hour I want to recalculate ...
0
votes
1answer
520 views
Formatting a date/time returned from a custom $wpdb query
I'm definitely a rookie WordPress/PHP developer, so please forgive ignorance :-)
Q: How do I format a date/time returned from a custom query against $wpdb?
Here's the scenario: I'm trying to write a ...
0
votes
2answers
7k views
How to parse row results from $wpdb -> get_results
I have the following:
$query = 'SELECT * FROM wp_pod_tbl_add_questions WHERE id LIKE '. $id;
$row = $wpdb -> get_results($query);
How do I get the ...
0
votes
1answer
964 views
Query and get meta as object(stdClass) on wp postmeta table?
I want to get a groups of data from postmeta table.
The postmeta table have 4 colums, meta_id, post_id, meta_key,meta_value.
Each post_id has a list of meta_keys.
I want to run a query and get a ...
0
votes
1answer
339 views
Subdomain redirect problem
Wordpress is installed my root directory(/root/). I have a subdomain(dammani.techbrij.com) and I want to access some files of main domain from sub domain.
I have done following thing:
...
0
votes
1answer
247 views
How do I query a table?
I am using Contact form 7 and the database extension, the db extension creates a table called wp_CF7DBPlugin_SUBMITS. I have 2 forms on my site, I need to know if the user has completed the 2nd form, ...
0
votes
1answer
16 views
Adding an orderby filter, casting postmeta with multiple keys
I am using this filter to sort my query by a date field stored as text (legacy data)
add_filter( 'posts_orderby', 'my_posts_orderby_date', 10, 2 );
function my_posts_orderby_date( $orderby, $query ) ...
0
votes
1answer
30 views
WPDB Query Question with Category Only
I am trying to pull up posts from only category ID 18 with this query for a plugin I am working on but it will not work. I can not use query_posts or WP_Query in the place I am using this.
global ...
0
votes
1answer
17 views
how does offset works on Pagination? (get_results)
I followed this link and created my own custom query with pagination.. but I don't really understand how the offset works,
Pagination with custom SQL query
the pagination does not work well. and I'm ...
0
votes
0answers
38 views
Retrieve post data via WPDB class
I'm trying to figure out doing a custom query using the $wpdb Object.
I have custom type posts, event_posts, that have meta data, images, as well as event dates which are input in the post with the ...
0
votes
0answers
42 views
Script timeout when importing/inserting > 45-50 posts from an external table
Wondering if anyone can spot the obvious mistake or give me some guidance on where I'm going wrong.
I should also state this is my first plugin with Wordpress, so I'm sure I have overlooked ...
0
votes
0answers
44 views
get_query_var('paged') giving same result
I have a custom page, in that page i am using a custom select query for my search functionality.
The problem is pagination not working. I used $on_page= get_query_var('paged'); for pagination. When ...
0
votes
0answers
58 views
Custom query on Wordpress custom table
I am working with a custom table where some values will be inserted or updated if they already exists, I have checked and rechecked the syntax and it seems to be working fine, if I run the same query ...
0
votes
1answer
12 views
Create Table Failed Column Date DateType
I have a plugin that creates tables and one of them is failing and I feel like it's due to either my syntax or the fact that I'm trying to create a column with datatype DATE and not TIMESTAMP (only ...
0
votes
0answers
28 views
Adding New attribute in wordpress
I'm using Wordpress to implement the website:
The pages in my templates should be sliding vertically, so there is a 'Next' button in the end of each page. Now my problem is in the admin section ...
0
votes
0answers
37 views
Filter content by custom field and category
Im trying to filter an Wordpress request with 2 parameters.
by a custom field (REGION) there are 6 regions
by categorie, there are n-categories with 1 value per post.
As result i would like to have ...
0
votes
0answers
67 views
wp_query orderby value not from meta_value
I'm using the myreviewplugin to add ratings to posts. I'm now working on the posts loop and customising the query using wp_query.
Everything is working fine, but I need to expand the orderby ...
0
votes
1answer
60 views
Select from wp_post and multiple meta_value from wp_postmeta
My lack of SQL skills has stopped me in my tracks here.
I'm trying to select post_id, post_title and two postmeta values - the first has the meta_key of 'search_country' and the second a meta_key of ...
0
votes
0answers
12 views
sequnce in enter words in wordpss search using query
I have a problem in creating advanced search with custom query and using $wpdb->get_results($query , OBJECT);
In Normal search in wordpress when we search xxx yyyy or search yyyy xxx we have same ...
0
votes
1answer
38 views
How to update user profile or inputing any data to the wp db from external site?
I need to update user profile field (mainly first name, last name, email and password) from an external website.
Wordpress is installed on wordpress.domain.com and external website is at ...
0
votes
1answer
34 views
Mysql query and odd results
I've a query here :
$sql = "SELECT ID,post_title,post_content,post_date,post_type
FROM {$wpdb->posts}
WHERE post_content LIKE {$stuff}
AND post_status = 'publish'
AND post_type = ...
0
votes
0answers
34 views
Not Creating New Database Table [closed]
I've successfully created tables with previous plugins I've messed around with, but I can't seem to figure out exactly what's wrong with this. Hopefully it's an easy fix.
//CREATE ...
0
votes
0answers
37 views
I am trying to send ajax collected data to the current users database
I am using WooCommerce and added an additional field "location_gps" to collect the location (lat,long) added the ajax call to collect the data. Now I'm stuck getting the data into the current users ...
0
votes
1answer
31 views
How to relate the Category to user?
I am developing one new plugin, In that i had a section to create new category, and having the field Created By(listing all the users in this field).
I am storing the category name in WP_terms and ...
0
votes
1answer
35 views
Using $wpdb to update current post
I have a function that expires posts on a date, and adds a check to the database. Now, I'd like the ability to "recycle" those posts with new expiration date, but in order to do this, I need to erase ...
0
votes
1answer
19 views
Cache metadata for set of posts
I have a query that can only be done using straight SQL, but I need to loop through the returns as a set of posts. As I understand it, WP_Query automatically gets all the metadata for all the posts ...
0
votes
1answer
57 views
Saving custom metabox data with a twist
I've got more than a few metaboxes being used with a custom post type and I'm running into an issue where my data is not being saved as expected.
Here is the relevant part of the code, and its within ...
0
votes
1answer
82 views
Custom counter when link is clicked in Wordpress
I would like to monitor the number of times a user clicks the hyperlink assigned with a class name link_counter. I'm using jQuery and PHP to do this, for example:
...
0
votes
1answer
60 views
How to check for empty and not a failure
I'm querying the postmeta table to see if a url has already been entered, using this statement (where $thisLink is the url I'm checking)
$mypostids = $wpdb->get_results("select * from ...
0
votes
1answer
58 views
Why is one one of these DB query methods (using a where filter) faster than the other (a direct get_var() query)? [closed]
In this thread I presented what I thought was a good answer, and @toscho presented one afterwards which to me seemed inferior.
But after running some timed tests, my code turns out to be ...
0
votes
0answers
13 views
Missing Argument: $wpbd->prepare on Wordpress 3.5 [duplicate]
Possible Duplicate:
$wpdb->prepare() warning in WordPress 3.5
In
/wp-content/plugins/extended-super-admins/class-wpmn_super_admins.php
called in line 90:
$networks = $wpdb->get_results( ...
0
votes
1answer
175 views
Custom query (author is post_author or meta co_author) with Pagenavi pagination
I need to create a custom query for the author archive (where the author is post_author OR is a meta co_author), and it have to work with WP Pagenavi.
The query is something like this (omitting $wpdb ...
0
votes
0answers
21 views
Missing argument WPDB PREPARE [duplicate]
Possible Duplicate:
$wpdb->prepare() warning in WordPress 3.5
Problem
I got this error: WARNING: MISSING ARGUMENT 2 FOR WPDB::PREPARE(), on this function:
CODE
function ...
0
votes
1answer
95 views
Post Bulk Update
Is there any way to update all the posts at a time through query or through admin panel.
For an example i am having an 1000 posts, how to update all the posts at a time.
Thanks.
0
votes
2answers
63 views
Can't get expected result from a wpdb query
Having some trouble with my first attempt at a direct DB query using $wpdb. I'm using the WordTwit plugin, and trying to retrieve the short url extension for the current post that is created by the ...
0
votes
1answer
125 views
wpdb inside foreach loop only returns first result - 2 other similar cases found
@Milo Problem solved, found spaces in the array $arrname.
I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key ...
0
votes
0answers
6 views
What would make a MySQL database create tables in a different collation other than its default? [duplicate]
Possible Duplicate:
Using wpdb to connect to a separate database
am adding tables to a Wordpress database on my localhost and it is changing my collation from utf8_general_ci to ...
0
votes
1answer
102 views
How to use remote db tables in current config? [duplicate]
Possible Duplicate:
Shared Members between two different wordpress installations with different databases
For example I have 2 different wordpress installations with different domains and ...
0
votes
1answer
182 views
WP_Query search by multiple meta key and distance
I am having two meta keys, longitude and latitude, and what I am trying to do is the equivalent of the google store location algorithm for distance, in wp_query:
SELECT id, ( 3959 * acos( cos( ...
0
votes
0answers
79 views
Hit counter adding hits to unrelated posts [closed]
I have created a simple hit counter by adding an additional table into my wordpress table
The table has columns (id, post_id, hits, post_type, date).
This is the function I've created:
function ...
0
votes
1answer
61 views
Compare string with post id in wpdb and do stuff when match is found
I'm looking for some help tying in with the wpdb to compare and change certain values. I'm very novice with mysql handling so I really appreciate any help on this matter!
What I want to do is to go ...
0
votes
1answer
130 views
Wordpress choose wrong database
I have 2 databases. When I include the database connection (with a include('filename.php');) wordpress acts really strange.
I can't login, the wordpress username and password is right but it tries to ...
0
votes
1answer
37 views
Nothing happens on Wordpress Update command
I made a function in Wordpress, which should update one field status to 0. But no changes are made to the database. I don't know what is the reason. Can someone please help.
I tried looking into ...
0
votes
3answers
188 views
pull custom fields values from wp-database in a nested foreach loop
I am trying to display custom fields on my template values of which i am pulling from postmeta table
doing something wrong with a loop or not writing the foreach args correctly not sure whats the ...
0
votes
1answer
86 views
Different sql queries count indicator on the main page
I use w3_total_cache plugin. But i can`t understand what is going on sometimes. I have enabled database caching and debug info at the bottom. Sometimes on the main page 90-96 db queries, sometimes ...
0
votes
1answer
91 views
Altering term_id and name via $wpdb class
$s = $_POST['submitterms'];
$querystr = "
SELECT $wpdb->terms.*
FROM $wpdb->terms
WHERE
lower($wpdb->terms.name) like '%$s%'
";
...
0
votes
1answer
105 views
How to reference same column name but different table in custom db query
I use wpdb to connect to a custom db, then I use the following query:
$my_row = $wpdb_c->get_results("SELECT Employee.Name, Area.Name, Area.Region FROM Area INNER JOIN Employee ON Area.ID = ...
0
votes
2answers
146 views
Get comments after specific date
I don't think this is a parameter in get_comments( $args ); so I'm using a SQL statement. First I obtain a comment date from a separate table I created. Afterwards, I want to retrieve all comments ...