Tagged Questions
-1
votes
0answers
25 views
Execute mySQL query on publishing of post
I would like to post some data to a db when certain categories are selected in a WP post. I would like this to action when the post is made.
This is the query I want to run:
mysqli_query( $con, ...
0
votes
0answers
30 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
30 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
80 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
60 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
75 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
346 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
50 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
432 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
221 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
86 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
255 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
48 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 ...
0
votes
2answers
54 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
313 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
365 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
291 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
573 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
189 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
434 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 ...