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

learn more… | top users | synonyms

2
votes
0answers
117 views

Custom WP_Query order by post_meta and (author) user_meta

I am having an issue that i couldn't find on google and elsewhere. To put problem in the context. I am making a wordpress site where user can put their tutor listing for giving a tutorials, and i am ...
2
votes
0answers
72 views

wordpress query - orderby child post date

I have support ticket system which i have built using wordpress. The basic functionality is that when a "ticket" is created, it creates a post. When an admin replies, it then add a child post to the ...
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' ...
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
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 ...
1
vote
0answers
45 views

Query if audio attachment AND/OR custom field

I've been trying several things but to no avail... Searched, maybe not good enough though! I have posts that either have an uploaded audio file AND/OR has a Soundcloud link (which is a custom field). ...
1
vote
0answers
132 views

How to query all posts of a specific category, and any other category combination

Basically, I'm looking to query all post of category 'news', and any combination of other categories to display as Related News on single content type pages. So, if someone writes a post, and ...
1
vote
0answers
334 views

Include data from custom table in WP_Query

I'm building an Estate Agent website. They have a system where they add their available properties and sends them all to the main property portals. As part of this, the system also sends all the ...
1
vote
0answers
712 views

WP_Query orderby and tax_query

My goal is to have custom posts type's posts (CPT for simplicity) from a custom taxonomy (CT for simplicity) let say CT Hometown with slug Nebraska to be listed grouped by another CT, let say ...
1
vote
0answers
473 views

Slow meta_query with about 4 milion record on wp_postmeta

Although optimized wordpress all the way but still very slow as follows : I have converted from LONGTEXT meta_value field to TEXT Then create INDEX for this field ALTER TABLE wp_postmeta ADD INDEX ...
1
vote
0answers
804 views

Query by 2 values of a repeater ACF field

Let's say I have a custom post type called Film, with a repeater field called Showings, with fields start_datetime and discount. I need to make a query for those Films that have at least one showing ...
1
vote
0answers
1k views

How to get latest posts from each category in regular order

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a ...
1
vote
0answers
27 views

Order posts with a custom field but also without

I am querying and ordering posts with this code but my theme adds the custom field (cb_vote_nb_vote) only if someone clicks the "vote" button, since I am doing a listing, posts created without that ...
1
vote
0answers
71 views

Query posts dynamic date range

So, I'm using the following to filter posts: $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' ); $args['paged'] = $paged; ...
1
vote
0answers
86 views

Caption and title in img alt tag are the same?

I'm currently on WP 3.6 and noticed an unpredictable behaviour with the alt attributes generated by WP. If I have an image title, the title appears in the alt. If I have a caption, the caption ...
1
vote
0answers
159 views

Post 2 Post Site Search

I'm trying to filter search terms bases on categorisation created by posts 2 posts. I'm using the generic site search and then I've created a search filter function my_filter_the_search($query){ ...
1
vote
0answers
77 views

Wordpress Query orderby title with UTF8 string in title

I got posts with titles are in utf8 encoding. When I query posts with orderby is title, those with utf8 characters at the beginning are at the end. Example: post title starts with Đ are at the end ...
1
vote
0answers
57 views

Sorting main query by custom taxonomy slug

Is there a way to sort posts by custom taxonomy (shoe_color) ASC|DESC? I would like to do this using query_posts and passing the orderby=shoe_color into it. Here is the code I'm trying to work out: ...
1
vote
0answers
153 views

Changing status of Published posts which have less Content to “Draft”

function draftpost(){ global $wpdb; $prefix = $wpdb->prefix; $wpdb->query("UPDATE ".$prefix."posts SET post_status='draft' WHERE LENGTH( post_content ) <500"); } ...
1
vote
0answers
358 views

WordPress Query wp-terms SLOW

I've got a very large database in WordPress with lots of products in WooCommerce along with quite a bit of taxonomies. When querying the products on the front end it takes 1 minute or more. Here is ...
1
vote
0answers
77 views

register_taxonomy() take much queries

Sorry for my poor English, I'm russian. I have a problem by adding a lot of taxonomies. When I added about 80 taxonomies, I get the following results(without caching): before: 44 queries 0.352 ...
1
vote
0answers
72 views

Why orderbyb meta_value_num won't affect the generated SQL Query order?

I've exhausted myself with this and I couldn't figure out why when I do this $myposts = new WP_Query( array('numberposts' => 5, 'offset' => '0', 'post_type' => 'noticias', 'orderby' => ...
1
vote
0answers
73 views

Dynamically adjust single-posttype.php query, based on current taxonomies

I have a single-teamphoto.php template loading data from a Team Photo - Custom Post Type, showing team photos with team member names below, one photo at a time, with a navigation list of available ...
1
vote
0answers
98 views

category pagination got broken suddenly

i need some help here please! The pagination just stopped working suddenly with the default post type and default wp query, with plugin "wp-paginate" or even with next/prev arrows! It echo 404 error ...
1
vote
0answers
356 views

Exclude posts with taxonomy term from appearing on home page query

I am really confused about this one, I am usually pretty good at working out basic queries but I can't seem to work this one out. Please see below my index.php query. Now it is not your basic query ...
0
votes
0answers
3 views

Custom query filter not working on woocommerce category page

I am trying to make custom filter for my woocommerce website. Everything is working fine in the shop page, but when I go to the archive page the filters are not working. I am recording each filter ...
0
votes
0answers
11 views

View all multisite posts from one “hub” site

I'm creating a centralized blogging network for a client. The idea is that, on one of the many sites, the client can see a list of all the posts on all the sites. The interface for this would ideally ...
0
votes
0answers
30 views

Sorting Grids with Essential Grid and Events Manger

I am using Events Manager to control my Events, but Essential Grids to display previews of these events in various places throughout my site. An example of this is ...
0
votes
0answers
19 views

Echo multiple tasks if a common function exists

How can I echo multiple tasks if a common WordPress function exists. For example, I want to reduce the following: <?php if (function_exists ('pluginName')) echo someName (1); ?> <?php if ...
0
votes
0answers
21 views

Using SET statements in wpdb query

I'm running the following queries directly on the database: SET @curr_time = IF(TIME(NOW()) < '06:00:00', DATE_SUB(NOW(), INTERVAL 1 DAY ), NOW()); SELECT Start_Time as 'start_time', Title_Name as ...
0
votes
0answers
22 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
0answers
20 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 ...
0
votes
0answers
11 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
0answers
20 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
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
0answers
34 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
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
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
35 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
18 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
0answers
44 views

SQL Query for all posts in specific category

I try to add a custom field to all posts in specific category with a sql query. This query set meta_value of new meta_key as post_author value in ldn_posts table. Here is begin of the code (works for ...
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
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, ...
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
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 ...
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 ...