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

learn more… | top users | synonyms

0
votes
0answers
16 views

Hide empty categories from get_categories

I'm trying to hide the empty categories (with no posts associated) from a list in an archive page. I'm using hide_empty as suggested on Wordpress codex but it's not working, the code outputs all ...
0
votes
1answer
28 views

Limiting a filtered query

I'm struggling with this query. I have a page where I will show products launched from last month and this current month. (http://the.nett.mx/innvictus/wp/) Everything works great, but when I apply ...
0
votes
1answer
618 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
2answers
21 views

Show featured image as background image from postQuery

The code below gets the image but I want it to be a background image. I believe I need to save the image as a variable first and then echo it out somehow. My PHP is not great so please give an example ...
0
votes
2answers
106 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
0answers
16 views

Custom database query with accents returning no results

I have an issue where using accents in my custom database query (wpdb) returns no results. $wpdb->get_results( "SELECT * FROM table WHERE city = 'Montréal'" ); Returns nothing, while ...
12
votes
8answers
65k views

What SQL Query to do a simple find and replace

Whenever I create a new website I first create a staging site on a subdomain like "stage.domain-name.com". After everything works correctly I export the database, open it in notepad++ and do a ...
0
votes
0answers
9 views

Filter User Query via URL Like Posts

I have two taxonomies assigned to users and I use them to create a user query and output the users. One of the taxonomies is ESPECIALIDAD, the other is REGION. When I am in: ...
0
votes
1answer
780 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
1answer
444 views

Display most viewed post from last 30 days is not working correctly

I've try several different loop to display the most viewed post from the last 30 days . . However its just showing the post from 30 dasy ago . . not from the last 30 days . . not the most viewed . . ...
0
votes
0answers
17 views

Use $wpdb->get_results with filter based on array

I need to filter my SQL query (in a plugin) based on an array of meta_values. I have CPT-A which is related to CPT-B. I am keeping an array of CPT-A ids in meta_key afz_entry_tags of CPT-B I need ...
0
votes
2answers
449 views

Custom search SQL Query to add custom field in result

I have to write my own MySQL query since I haven't found a good way to do it within wordpress functionality. I want the search query to search trough post_title / post_content & meta_key ...
0
votes
2answers
55 views

Conditional posts in WP_query for search

I have a custom post type that im trying to limit results in search. The CPT is a deal/coupon, with a start and end date for each of the deals. What I'm trying to do is only show these posts in ...
3
votes
1answer
9k views

Retrieve posts by term id custom query

i want to retrieve custom posts using using custom query . my taxonomy is recipe_tx and terms (Beef) , (Chicken) etc in it . i have tried using SELECT p.* FROM wp_posts p, wp_term_taxonomy tt, ...
0
votes
1answer
12 views

wpdb get posts by taxonomy SQL

I need a list of posts of a specific post_type plus the name of a custom taxonomy term. This is what I got so far SELECT p.post_name,t.name as clientName FROM $wpdb->posts AS p, $wpdb->terms ...
0
votes
2answers
564 views

Get ID of child from child slug, while knowing parent ID

I have a hierarchy that I need to get data from. It's the child (by slug name) that I need to get while already having knowledge of the parents. Highest Known Parent Page (slug : 'parent') |_ Child 1 ...
1
vote
1answer
18 views

How can I get the query that would be run for the archive page?

When a user visits a post type archive page on my site, I've got a bunch of hooks and filters that run on that query and get it just so. How can I, in a different request, say "I want the query that ...
4
votes
2answers
424 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?
0
votes
1answer
15 views

Wordpress PHP syntax doesn't seem to be working correctly

When I run this wordpress query, instead of the background image showing I just get the end of the div string echoed out? The image string appears in the browser inspector, but not to the screen. Here ...
0
votes
1answer
894 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
votes
1answer
10 views

database search feature

I am looking to create a website that creates and searches the created database then displays the results on a custom page. I initially thought this would be a lot easier than it is proving to be. I ...
0
votes
1answer
22 views

Customizing the_tags output?

I am trying to display a list of tags. I want to display 6 tags but random tags. Not post tags but tags from the entire site. <?php $number_to_show = 10; $tags = wp_tag_cloud( array( ...
0
votes
0answers
21 views

Limit results of custom query to current category

I have created a geolocation system for a custom post type of services and have been working on a query to limit the results based on address/distance entered by the user. Everything seems to be ...
0
votes
1answer
474 views

Delete data from custom table in wordpress

i am trying to delete record from my custom table global $wpdb; $retrieve_data = $wpdb->get_results( "SELECT * FROM wp_paypal" ); echo '<table border=1 class="table table-striped"> ...
0
votes
0answers
20 views

How to use pre_get_posts filter from frontend user input (GET variables) or do_action

I'm trying to allow users to filter certain pages based on the input from a dropdown. <div class="filter-by-calories"> <h3 class="filed-title">BROWSE BY CALORIES</h3> ...
0
votes
3answers
1k views

How to delete all posts, categories and tags from Wordpress database

I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this ...
1
vote
1answer
657 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
2
votes
2answers
2k views

Get category slug and display it on a query_post

I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories . there is two parts to my question - Part A - Get category slug and ...
0
votes
1answer
789 views

Load more posts with multiple queries

I've been developing a theme which uses the load more ajax plugin, everything is setup and working great with the main query. But, once I setup a new query for popular posts, the load more posts ...
1
vote
2answers
530 views

How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently ...
0
votes
2answers
457 views

get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)

I have this piece of code which works but it's showing only 5 posts (with custom taxonomy) where should be 7. If I hit the tag url, it shows the 7 registries, so the problem it's in this code and its ...
0
votes
2answers
95 views

sql for querying post and their category

I'm trying to query the wordpress database for the post and what category they belong in. Is there a sql query that I can use for this? Thanks,
0
votes
1answer
495 views

Delete query won't run

This is the set up: <form method="post" action=""> <input type="hidden" name="delete_app_id" id="delete_app_id" value='<?php echo $adoptee->app_id; ?>' /> ...
0
votes
1answer
36 views

Query Posts that have or don't have a meta_value and order by the same ASC

I'm trying to perform a scheduled update to all posts, 10 posts at time. To achieve this, I run Cron job with a script that saves 2 post meta: $DATA: the data I want to be update $TIME: the UNIX ...
0
votes
1answer
496 views

WP_User_Query with more than two custom meta values

I am trying to create a custom user query based on users' metadata. I have the following query created. $users = new WP_User_Query( array( 'search' => '*' . $search_name . '*', ...
-1
votes
2answers
23 views

Can't See Media Queries with Inspect Tool [closed]

all - I do not have the greatest CSS skills in the world, but I can normally figure things out. Right now I'm trying to implement a fairly simple media query in the child theme of my Wordpress site. ...
0
votes
1answer
2k views

Retrieve and display data from custom db table in admin area?

So, i'm having a bit of an issue with a plugin i'm developing, I wonder if anyone can shed any light on the situation, as many, MANY searches have come back with zero help. :-/ Basically, my plugin ...
1
vote
0answers
18 views

Query with relation and one without relation using multiple taxonomies?

I'm trying to use one query for two queries, one with an and relation and one without without having to do multiple queries and loops, is this possible? <?php $args = array( 'post_type' ...
0
votes
1answer
26 views

Query custom post type by custom taxonomy (category slug)

I've followed several related solution. But I'm still facing the problem. I've applied the following code for my custom post query by taxonomy (category). But it's not working. I think my problem with ...
0
votes
1answer
41 views

$query->set( 'post_type', 'post' ); not working

I am trying to exclude pages from my search result with this function: function posts_for_current_author($query) { global $user_level; if($query->is_admin && $user_level < 5) { ...
0
votes
1answer
52 views

Show recent products first but “sold out last” in query

I am using WooCommerce and would would like to show the "out of stock" products last in the query on the archive page. How can I do that? Currently we are making the newest product show first with ...
0
votes
1answer
21 views

Exclude current custom post on single post

I'm trying to exclude the current custom post that is viewed from a list. I've tried with exclude but it still displays it. Here is the code I have on single-works.php: <?php $currentID = ...
0
votes
0answers
16 views

A simple way to unfilter the closing h2 Tag in the excerpt

normaly the Wordpress Excerpt is beeing filtered. For some auto correction inside a Plugin i would need to know where the h2 tag ends, and finally to set a dot on its place with a preg replace. I ...
0
votes
3answers
46 views

is_main_query() never called on WP 4.4

Im fairly new to WP dev, however as far as i can see ive followed the correct procedure in my custom archive page (below). If i remove the check for is_main_query() it wipes the menus out and likely a ...
0
votes
0answers
23 views

Archive page: how to orderby category and then by author?

Is it possible to display an archive page ordering its articles by (sub)categories first and by author (alphabetically) as second level order? What do I need to modify and where?
0
votes
0answers
33 views

Query can not search data with space?

I have following code $wpdb->get_results( 'SELECT * FROM '.$device_token_table.' WHERE user_pushtoken="'.$server_method['user_pushtoken'].'" AND user_id = '.$user_id,ARRAY_A ); ...
0
votes
0answers
17 views

Order posts by a descending meta key integer value and append posts with no meta key after them

Let's assume that there are 10 posts. 8 of them has a votes meta_key with an integer value associated to it: key => 'votes', value => 5 But 2 of the 10 posts doesn't has a votes meta_key at all ...
0
votes
1answer
57 views

Wp_query WooCommerce products

I'm currently developing an e-commerce store using Wordpress and WooCommerce. I'm planning on creating a basic product filtering system and was wondering if it's possible to wp_query the results shown ...
0
votes
1answer
50 views

Check if CTP category taxonomy is set in shortcode

I have created a custom post type with the ability to add categories (taxonomy). Taxonomy function create_cat_tax() { register_taxonomy( 'cpt_cats', 'cpt_faqs', ...
2
votes
1answer
38 views

WPDB Multiple site's posts and get featured images

I am using the code below to query 5 Wordpress sites for their posts, merging them into an array, sorting the array by date, and then displaying them: //SITE 1 $mydb = new ...