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

learn more… | top users | synonyms

0
votes
0answers
32 views

Fast User Query Using SQL vs WP_User_Query

I've found that WP_User_Query() is very slow when dealing with more than 1,000 users and I have decided to use custom MySQL queries. In my code below, I pulled only user_id to make it work faster and ...
0
votes
1answer
50 views

Improving WP_Query for performance when random posts are ordered

I have made a new query after I've asked a question about my query_posts code... you guys didn't find that great, so I decided to change that. I made this: $page = (get_query_var('paged')) ? ...
0
votes
0answers
29 views

Rewrite URL query string for all pages

I need to pass query string http://example.com/anypage?query=123 to look like this: http://example.com/anypage/123 and it should work on any page: ...com/anotherpage/123 I am looking for the ...
0
votes
0answers
36 views

Meta Box Plugin - Adding field value inside echo

I am using Meta Box Plugin to add some custom options to my Page Edit. I added a field to add an image background to the header which is working great. This image background has a parallax background ...
0
votes
0answers
18 views

Add Hook for clearing transient when post is added

I have this fragment caching implemented in a page. I've got the codes from https://css-tricks.com/wordpress-fragment-caching-revisited/. Which goes like this: function fragment_cache($key, ...
3
votes
1answer
34 views

Difference between fragment caching and wp_cache

I've been really confused about this two caching. What's the main difference of fragment caching vs wp_cache? Can both of them be used hand in hand? EDIT i've read about the fragment caching found ...
0
votes
2answers
54 views

Check return value of get_posts

I've been trying to change my WP_Query to get_posts methods. But I am not really sure how to check if get_posts is null or have a value. How can i transform this WP_Query checker to appropriate ...
0
votes
1answer
57 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
vote
1answer
31 views

unable to retrive parent page information

I am trying to display the parent page title, parent page id, current title and current id on a page via a plugin. I have the below code which I then echo the value of each. The trouble I am having ...
1
vote
1answer
52 views

Change query_posts to WP_Query in page but does not work

I have this code in page.php and it calls the template part for my home. Inside the home.php i used query_posts instead of WP_Query and i wanted to change it into WP_Query. I tried changing it but ...
0
votes
0answers
16 views

Excerpt data from one page into another

I'm a comparative noob at working inside WordPress. I'm trying to do my homework before asking, but haven't been able to uncover answers to the following. I could use your expertise. I'm working ...
0
votes
2answers
24 views

WP_Query with child element

I have my calendar events, I want to sort them by creation date with the query, but here's the issue: I have a meta key which has child values: First one is $data = ...
0
votes
1answer
32 views

$wpdb query for price in custom field value

A classifieds list site have only 3 criterias when searching products: the common search, category and region (for ZIP, city or full address) It's not enough and I really need to include a basic price ...
1
vote
1answer
44 views

First custom field value (out of several) displayed twice after query

I have the following piece of code, which is based on the solution to this question: <?php $game_titles = get_terms('game'); foreach($game_titles as $game_title) { ...
1
vote
2answers
65 views

Create WP_Query to search for posts by their categories or their parent/child categories

Hello I am really sorry if this has been asked before but I couldn't find the exact solution I need. So here's the problem I want to create a search in my Wordpress page. Whenever a user submits the ...
0
votes
1answer
28 views

Having trouble going from Jfiddle to implementing in Wordpress :(

If someone could point me in the right direction on how exactly to do this without yelling about follow codex site lol. I wouldnt be here if I wasnt able to get it working haha. I created a neat ...
0
votes
1answer
51 views

Alternative layout the loop

i'm trying to make an alternative loop as found here on stackexchange, it has been a great help to what i've achieved so far, but i'm stuck now. The goal is to make the newspage look like this The ...
0
votes
0answers
29 views

Function returning same value for all posts

I have this function to get the size in KB from a file. It works like a charm as long as it's on a single post. However, if I do a query, all posts take the value from the first post. Thus, if the ...
0
votes
0answers
9 views

Query Code Making Menu Disappear

I'm trying to display only certain tags on my site, but when I use the code my menu disapears. Heres what I have: $query->set('tag', 'break','crunch'); return $query; I have this placed in the ...
0
votes
0answers
19 views

SQL query works only if inclusive

I have a Wordpress website with, say, 5000 articles. I am trying to apply a query to filter all the posts with featured images not listed in some specific categories. I started with: SELECT ...
2
votes
1answer
42 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 ...
0
votes
0answers
19 views

Adding Facebook & Twitter Cards

This might be a stupid question.. But I'm working on a website for which I would to integrate twitter/facebook cards and things of that nature. Is there a good way to call those <meta> tags into ...
0
votes
2answers
120 views

Query posts between two dates (custom meta keys) CMB2

I have a custom post type (projects) which have custom cmb2 meta keys (str_dte and end_dte), so each project has a start date and end date. What I am trying to do is to get projects between two dates. ...
0
votes
0answers
43 views

Is there an efficient way to query posts's ACF gallery field?

My setup is as below. Custom post type > Page > Custom field (Gallery field) [only one gallery per post] And below is the code that renders all the galleries from the posts on a ...
0
votes
1answer
37 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
140 views

wp_dropdown_categories with multiple select

in the search box I would like visitors to be able to search for more than one location (houses). The code right now is: <div class="col-md-3 col-sm-6 col-xs-12"> <label ...
1
vote
0answers
30 views

Prioritize posts in query by meta keys?

I have a CPT called jobs. In my single jobs page I am counting page views with these functions: /********* Post Views counter ***********/ remove_action( 'wp_head', ...
1
vote
1answer
42 views

WP Query with custom Shortcode

I have the following in my functions.php:- /** * Shortcode: Latest Properties */ function latest_properties_func( $atts ) { $args = array( 'posts_per_page'=> 5, 'post_type' ...
0
votes
0answers
25 views

Query Custom Post Type that doesn't have a specific Custom Taxonomy [duplicate]

I have a CPT 'catalog' and a custom taxonomy 'catalog_category' attached to it. I need to query for all 'catalog' items, that don't have any values of 'catalog_category' selected. These arguments ...
0
votes
0answers
30 views

Custom query for tag and custom tag from 2 post type

I have custom post type called items and added custom taxonomies type and sub-type. I like to query posts from both post and items post type that has art as either Tags or Sub type. Below is what ...
0
votes
1answer
40 views

Query for Custom Post Type UI Does Not Loop All the Post

$args = array( 'post_type' => 'lirik_melayu', 'orderby' => array( 'ID' => 'DESC' , ), ); $query = new WP_Query( $args ); $query_contents=Array(); while ( ...
0
votes
1answer
57 views

Query posts according to specific post meta values

I have a loop in my index.php for my home page like this... <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> I have a function to query the posts by ...
0
votes
1answer
18 views

Querying for specific tags

I currently have this code that pulls all of the tags and creates a list with links for them: <?php $tags_array = get_tags(); foreach( $tags_array as $tag) : $tag_link = get_tag_link( ...
1
vote
1answer
26 views

Get posts by name and taxonomy term

How do I get all posts that has a taxonomy term and a specific name/slug? I have tried with the following arguments but without getting the wanted result. What am I missing, how can I combine the ...
0
votes
1answer
11 views

Get posts associated with media attachment

Is there a good way to find all posts that contain a specific image? I'm working on the attachment single template, and I'd like to list the posts that contain that image.
0
votes
0answers
16 views

query order by a function

I was wondering how to order posts by a function that returns a number. I've set up a query and i want to order my post by that number. Here is what I have: $foo = get_like_count(); and in the ...
0
votes
1answer
20 views

Post with certain term and without any term

I try to create a plugin to manage user groups with permission to view posts within group and I stopped because of query problem. Example: User belong to group called "Group #1" (slug: group-1). I ...
0
votes
0answers
38 views

Custom Tax Query with special characters

I have this query that pulls posts form multiple custom taxonomies. IT works 98% of the time, the only time I have problems is when the term name has an apostraphe or special character, is there ...
0
votes
1answer
33 views

Sort by meta key within same day

I try to build something that can sort posts by day - and whithin the same day sort them with any meta value (integer) - like popularity or vote or what have you. So that, in the end, i get today's ...
0
votes
0answers
23 views

Query Search Not Working for Users

When I search for a User by their first name, all of their posts show up in the dashboard. When I search for that same User and add their last name, it does not show up at all. Not sure why this is ...
0
votes
1answer
398 views

WooCommerce - Query for ordered products

I'm trying to obtain all orders for particular day/time and then order products using SQL (MySQL) as seen in the query below: select p.ID as order_id, p.post_date, i.order_item_name, ...
-2
votes
1answer
23 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 ...
0
votes
1answer
19 views

List of authors posts minus very latest

I'm creating an authors.php page to display all the posts for the author clicked. But the list(s) needs to show the very first / latest post so I can style it diferently than the rest of the posts? ...
0
votes
1answer
90 views

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global ...
0
votes
1answer
138 views

cron job to auto delete posts of a specific post type older than x days

I want to delete all posts of a specific post type (in this case "vfb_entry") that are older than 60 days. The cron job should run once a day. I have the following code but it's not working if I ...
-2
votes
1answer
22 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 .
0
votes
1answer
51 views

Custom Query - Based on user input

I'm working on displaying suggestions to an input, assisting the user. I'm using the included jQuery suggest. That's loading - and through ajax I'm using a custom SQL query and can see it's ...
0
votes
0answers
20 views

Query Database for URL

I have a multisite setup and was wondering how I can query a database to find and retrieve a URL if it exists, otherwise, don't output anything... For example, using the two following domains which ...
0
votes
1answer
50 views

wp_posts query slowing down my website

My website's been incredibly slow and I installed the query monitor plugin to learn more about the issues that caused this. When loading my index page, the following query takes 0,2412 (seconds?!) to ...
1
vote
0answers
41 views

Query to get number of posts last week

I want to receive each monday the number of posts that were posted on my site during the week. The first part of the code retrieves the number of posts, and the second part sends me an email with the ...