0
votes
0answers
5 views

How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category

I have tried the following phpMyAdmin query in an effort to delete all posts, from wordpress category 378, that are over 400 days old. delete a,b,c,d FROM wp_posts a LEFT JOIN wp_term_relationships b ...
0
votes
1answer
24 views

How Do I Merge Categories With phpMyAdmin

I tried the following phpMyAdmin query to merge my category 112747 into my category 112748: UPDATE wp_term_relationships SET term_taxonomy_id = 112747 WHERE term_taxonomy_id = 112748; It did not ...
1
vote
0answers
12 views

Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin

I have a wordpress table like so (phpmyadmin and MySQL) | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | ...
1
vote
1answer
14 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
0
votes
2answers
53 views

Wordpress and a secondary database?

I have to achieve something on which I don't know how to approach it. Base of the issue: There's a bunch of data in another DB that I have to import into WP which so far wasn't possible due to them ...
0
votes
1answer
21 views

Connecting to a 2nd DB gives me no results when querying

I'm trying to access a different DB on the same localhost as my wp db is and I did this like so: functions.php: add_action('init','my_new_db'); function my_new_db(){ $newdb = new wpdb( 'test', ...
1
vote
1answer
38 views

Query Wordpress database by registered date and role

I would like to get the display name and email address for all users who have registered to my multisite today with the role of subscriber. It needs to be an SQL query as it's used outside of the WP ...
0
votes
0answers
21 views

How Can I Put Meta_Compare in the Database-Query?

Yes, I know that this can easily be done with built in wp_query but I need this in Wpdb query. I have a custom field and I need to display posts where this field does not exist. By the way can I get ...
0
votes
1answer
40 views

How to display data from db in select list [closed]

I wonder what it's wrong in my code. I can't get all of data in column "adres". In result I only have the lest record. Thanks for help. global $wpdb; $result = $wpdb->get_results ("SELECT ...
1
vote
1answer
23 views

How can I get a list of comments by target

I've been looking at the classes WP_Comment_Query and WP_Meta_Query but to be honest, I can't figure out how to use them together. I want to query the database for comments where wp_posts::post_author ...
0
votes
1answer
171 views

Query multiple tables at once?

I want to query all of the posts in my WordPress multi-site set-up looking for a certain string. This is only being done in Sequel Pro (on the command line) for my own inquisitive purposes but there ...
0
votes
1answer
26 views

Using class id from array for query

I'm using Event Calendar 3. Since there seems to be no easy way of querying all upcoming events as posts, I tried it this way, getting the IDs from the DB and querying the posts from that: <?php ...
0
votes
0answers
65 views

Combine Query and Select Database to create directory loop

I have a query loop on my page that I am using which displays all users on the page with certain custom fields filled out. It's working fine however, I need to also query these users for their level ...
0
votes
1answer
97 views

Best practice to limit results in get_row()?

This is my query to check if a title exists (it's in a loop, therefore [$i]). $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . $titles_arr[$i] . "'", 'ARRAY_A'); Anyway, I would ...
0
votes
0answers
123 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
286 views

PHP variable in WordPress database query

When running the following code : $voucher = 'MK0186'; $is_in_database = $wpdb->get_results( "SELECT * FROM my_codes_table WHERE code =" . $voucher ); I get : WordPress database error: [Unknown ...
0
votes
1answer
321 views

Get a custom table to an array

How can I take my table I created like this: global $wpdb; //Get all the wordpress database stuff $table_prefix = $wpdb->base_prefix; //Get the global prefix for all sites (on a multisite ...
1
vote
1answer
914 views

Custom search page and search by title, content and tag

Can someone review my code , I need to know better solutions or any bug. Okey ! , I made a PHP file to get search results by parameters and search by title , content and tag PHP's head look like: ...
0
votes
1answer
64 views

How do I find users by password?

I need to add a passkey to each user, so I decided to just giving the user password that value and use WP functionality to store it/retrieve it. So now I need to find what user that password belongs ...
4
votes
2answers
1k views

Count & Display Database Queries

I'm looking for an solution how I can count and display all queries in a WordPress site. Does anybody know, if there is an good plugin? Otherwise it would be an solution to check the queries on the ...
1
vote
1answer
581 views

WP_Query Performance Issues with meta_query

I'm working on a custom template for a new theme that uses a WP_Query instance to select posts from 2 post types with 2 custom fields that are NOT empty. Depending on the section of the site, a ...
1
vote
2answers
97 views

How to organise this data within WordPress

I have a dilemma in how the data in this scenario should be organised, as well as queried. The main elements in the scenario are the following: Competition Team Player Each player plays for one ...
0
votes
1answer
302 views

How to query / DB requests?

what is the correct way to query the a Wordpress database, meaning to pull row and column info, and then place it into a corresponding table in the Wordpress admin? I'm wanting to do a query similar ...
0
votes
1answer
54 views

How can I query the db to access current post information?

Alright y'all. I want to dynamically display the information of the 2 most current posts to the screen. So far I have only been able to get results by hard coding the ID into the query. Is there a way ...
1
vote
2answers
57 views

plugin code is pulling information from database in one instance and not in other. What is wrong?

In my plugin code, I am pulling the table id from two tables. The id is being pulled from one table but not from the other and I get errors in both instances. The queries work on mysql when I use ...
1
vote
2answers
656 views

Query from a different database than the default

I'm making a layout for a wordpress page. The layout needs to connect to a second database (both databases are in the same domain). But the problem is, when i execute just the file it works. But ...
0
votes
1answer
420 views

How to display content from external db with relevant urls

I am working on a website that needs to display information about electronic resources which is stored in an external database. This information will be presented three different ways (alphabetical ...
0
votes
1answer
360 views

How Can I Always Display A Particular Post First Using WP_Query?

My apologies if this question has already been asked somewhere else, I searched but couldn't find anything. I am working on a tours website, there will be individual package pages that show some text, ...
1
vote
4answers
2k views

Export wordpress table to excel

I have created PHP scripts before to export a database table to .xls format like this: $select = "SELECT * FROM tracking"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ...
0
votes
3answers
747 views

How to find if a post with custom_field == X exists?

I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?
1
vote
1answer
200 views

WP database error for comments_popup_link()

I'm using the comments_popup_link() function to show the number of comments for each post in a loop. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if ( ...
0
votes
1answer
512 views

SQL error with custom query

I'm trying to create a custom post query for sorting posts that have been voted "thumbs up". I'm joining my custom "wp_post_votes" table (which stores the number of votes each post received) with ...