We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [query]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
61 views

Display one post randomly from category on home page

I have a custom post type called "Milo-Books" and a category named "Featured" with ID of "100". I want to run a query which pulls out on post from this category on the homepage, but randomly and I ...
0
votes
1answer
85 views

How to query different categories on index?

I'm new to WP and I want to know how can I show latest posts on different categories separately in blog index ? one section for latest post on Fashion category, one on Health posts, etc. I know about ...
0
votes
1answer
173 views

Ajax Query returns zero

I am doing simple wordpress select query and want to do this with ajax jquery and do not want the page to refresh when I press search button and writing text in search textbox. As soon as I press ...
0
votes
1answer
116 views

WP_User_Query. Whats wrong with 'relation' => 'OR'

I want all the users who meet either Condition1 OR Condition2. Sort by last_name. If I take condition1 AND condition2 ('relation' => 'AND'), the query is OK. If I take 'relation' => 'OR', I get all ...
0
votes
1answer
1k views

Wordpress: paginating array using a foreach

I currently grab an array of user data from a query. I then use a foreach to loop through them and apply styles and divs to output them to the page. This all works great but i would like to paginate ...
0
votes
1answer
384 views

Does wp_query and query_posts affect website performance? [duplicate]

I've been aware about the difference of wp_query and query_posts. I just want to know what impact does both query methods to the performance of the page? Which query method makes the page load quicker ...
-1
votes
1answer
24 views

how to use transient method?

It was suggested to use a transient method to remove the duplicate queries Duplicate Queries Why does this don't work? Is it the wrong way to use it private function get_acf_list() { if(!...
-1
votes
1answer
31 views

How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page

Let's assume that the $wpdb->query() is properly escaped as needed, so there is no must for use of $wpdb->prepare(). However, some new requirements at Envato, not the w.org, requires to go over ...
-1
votes
2answers
147 views

How to specify what kind of is_single post?

I have two different kinds of single posts, blog and products, built in the same way with post categories. The blog has three static categories that the user will use, News, Updates, and Ideas. This ...
-1
votes
1answer
1k 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 = '$id'...
-1
votes
3answers
1k 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. ...
-1
votes
1answer
191 views

How to get one result using wpdb class?

function asec_get_link_color() { global $wpdp; $query = "SELECT value FROM wp_theme_options WHERE property = 'link-color'"; $result = $wpdb->get_results($sql); return $result; } ...
-1
votes
2answers
75 views

Wordpress Unknown Query

I have the following query and i can't find where is executed SELECT count(ID) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts....
-1
votes
1answer
188 views

Query Concatenation

I can't figure out how to properly concatenate my PHP variables in my MySQL query. $convert_class_id and $convert_char_id are holding numerical values. When I try to activate my plugin I get an ...
-1
votes
1answer
279 views

WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN

So here's the situation, we have a WP DB that has +/- 300k posts, and there is a complex query that has to be done checking different metas and crossing different info, etc. Here's the query: SELECT ...
-1
votes
3answers
366 views

Font size on image captions on mobile

I am using this css code on my theme in order to get the styling under an image in a post: .wp-caption .wp-caption-text { font-size: 16px !important; color: #000000; text-align: center; ...
-1
votes
2answers
234 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. ...
-1
votes
2answers
2k views

show all custom posts types in home page

Hi i am working on custom post types in wordpress presently we are using below code to display the custom posts, but the thing is the custom post types are keep on increasing, add_action( '...
-1
votes
1answer
172 views

paged query leads to 404? [duplicate]

As soon as I click the "2" on my pagination links I get a 404-error. The url correctly changes to http://mysite.com/?paged=2 <?php /** * The loop that displays the posts. */ ?> <ul class="...
-1
votes
1answer
149 views

How to insert a variable into a query parameter?

I need to put a variable into query parameter. I have this situation: $variable = get_field(loop_category); $catquery = new WP_Query( 'category_name=***VARIABLE-HERE***'); while($catquery->...
-1
votes
2answers
3k views

How to get current user ID in array meta_value?

Here is example: $args=array( 'meta_key' => 'Something', 'meta_value' => '',//here goes current used ID by default. 'meta_compare' => '=', ); $user_query = new ...
-1
votes
1answer
2k views

WP insert post PHP function dynamically generated Custom Fields

Further to my previous question WP insert post PHP function and Custom Fields We have a working insert post function that can also send over custom fields without yet knowing the ID. Please see the ...
-1
votes
0answers
11 views

How do you query custom post types with the same category name as the post title?

How do you query custom post types belonging to a category with the same name as the default post title of the post where the post types are displayed?
-1
votes
1answer
38 views

SQL Query : how copy all tags of post into their post content in wordpress by sql query

I want to copy/move all tags of a post into posts content, as text form not in a link form. For example: A post has: a title in title field, some content in content field (like: a ...
-1
votes
1answer
214 views

wp_query on search results page showing all results every time

I am trying to build my search results page, and I am using wp_query. However, overtime I search something all of my posts are showing up instead of only those posts that match the search. Why is ...
-1
votes
1answer
98 views

WP_Query not returning results

I have problem with my WP_Query, I want to display results with my custom query, I'm using Advanced Custom Fields <?php // Get data from URL into variables $miejscowosc = $_GET['miejscowosc'] != ''...
-1
votes
2answers
205 views

Main loop querying current template's info only in custom category archive pages, not my posts

I have a question about reasons why the main query would call the current page's info when using a template file, instead of querying the posts. If I modify the loop by creating a custom query ...
-1
votes
1answer
67 views

How to set value in Query Loop?

I have a Query: <?php $feature_big = array( 'posts_per_page' => '1', 'meta_key' => $count_today, ...
-1
votes
1answer
158 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 ...
-1
votes
1answer
950 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 ...
-1
votes
1answer
230 views

query grandchildren taxonomy terms

I have a function that queries the children of each taxonomy terms, I'd also like to query the children of these children terms too, my markup is as follows: <?php $terms = get_terms("...
-1
votes
1answer
91 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 ...
-1
votes
1answer
841 views

How to add multiple values with add_query_arg?

Let's suppose I am on this url of my site http://demo.com/?cat=1+2+3 And now someone clicks on a link generated with add_query_arg(). How can I make this link go to http://demo.com/?cat=1+2+3+4 Im ...
-1
votes
1answer
15 views

The page that displays Posts on homepage

I want to know the page responsible for displaying the blog posts in WordPress. Where I can probably expect to find the SQL query and post rendering so I can edit some stuff by myself.
-1
votes
1answer
122 views

Highlighting Sub topic in a post?

Have seen this sub topics highlighter in many blogs. It gives a special attraction to a sub topics used in the post. Is this a plugin or part of code? How can I add this? http://imgur.com/UbGpz7j
-1
votes
2answers
1k 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; ?>' /> <...
-1
votes
1answer
402 views

Multiple loop with pagination in same page

In my home page i have two <section> in which i perform two different loops on different post categories. Here the code: <section> <ul class="loop-article"> <?...
-1
votes
1answer
108 views

query_post or single-[cpt].php?

php query_posts( 'post_type=listing'); Or single-listing.php? According to my reading I have presumed that to display a custom post type all I need to do is copy my single.php and rename it ...
-1
votes
2answers
1k views

List of buyers for each product

I would like to know if it's possible to get the complete name of each buyers for a specific product or the orders list of a specific product ?
-1
votes
2answers
7k 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 ...
-2
votes
2answers
828 views

How to display search query as formatted text?

I am trying to display a site vistors search query on the search page. The form has custom fields so is not showing if it's "Search" and it doesnt show none of my custom fields. My search form - &...
-2
votes
1answer
923 views

Add a class to a menu item depending on a body class

I need to have a class of current-menu-item added to a li with the id of #menu-item-127 if the body class is post-type-archive-team I can do this with jQuery - $(function(){ if ($('body')....
-2
votes
1answer
141 views

Where can I find the SQL to get the most used information by wordpress database?

I tried to google "wordpress sql to get post url" and I was pretty astonished I couldn't find any resource sharing the SQL code to join the wp_post table with the table containing the permalink. How ...
-2
votes
1answer
483 views

query posts only works on the first page

I'm using Jetpack's infinite scroll function on the homepage and I only want to display posts from the category with ID 1. The problem is that my query works correctly only on the first page. On the ...
-2
votes
1answer
152 views

Include plugin´s table in custom query

I rephrased the question, following the suggestions of the contributors (below) helping on it. As we know, WordPress search by default only incudes in this search function de wp_posts database table. ...
-2
votes
2answers
247 views

How to show posts of a specific category

I am new with word press and I want to show the post of a specific category on my page. The name of the category which i want to show is home slider. Below is the code which I have used to display all ...
-2
votes
1answer
153 views

Get Posts ordered by a date custom meta field

I have created a meta field for a custom post type. This is a date field that will always be YYYY-MM-DD. There could be 100s of posts so i cant query them all and sort afterwards. I need to be able to ...
-2
votes
1answer
26 views

Show post like this image in my newssite [closed]

I want to know how to query like this photo in my newssite for a category. See this image and help by give the query code. Do I use Offset or if else. How to query for this .
-2
votes
1answer
340 views

Custom Query for wp_posts using wp_postmeta

In postmeta lets say meta_key = 'count' and meta_value = '5' meta_key = 'count' and meta_value = '6' meta_key = 'count' and meta_value = '7' now i want to get all post WHERE meta_key = 'count' ...
-3
votes
2answers
137 views

Query parsing only author ids

I need array only all author ids from the loop, each one only once if possible and out of all posts in the loop. Any suggestions?