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

learn more… | top users | synonyms

2
votes
0answers
106 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 ...
1
vote
0answers
23 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 ...
1
vote
0answers
17 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
20 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
36 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
110 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
283 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
593 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
392 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
690 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
963 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
65 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
85 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
153 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
75 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
146 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
354 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
97 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
349 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

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
16 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
6 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
16 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
10 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
0answers
11 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
0answers
18 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
0answers
10 views

Multiple relationships pods issue

I'm new at using Pods, which I find very practical. I'm experiencing some issues though; I'd like to create a model like the following-one : Entity type 1 |->sub-entity type a, refers to a specific ...
0
votes
0answers
15 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
0answers
23 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
0answers
13 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
0answers
17 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
0answers
6 views

Add current user filter on WordPress's default celendar

I want the WordPress default calendar to only show the posts from the current logged-in user. Not the entire posts of the site. I had to hack the general-template.php to do that but really need to ...
0
votes
0answers
36 views

Restrict access to custom post type and filter from every query

I created a custom post type topic which is just for internal use. I managed to assign the correct capabilities so that users of certain roles can edit/publish/delete posts. Now I want to redirect ...
0
votes
0answers
40 views

Show posts in numeric price order using meta query combining 2 meta keys

I've built a custom estate agency website for a client but I'm stuck on this one last thing before it's good to launch. I'm using custom meta fields to allow for additional meta data such as Price, ...
0
votes
0answers
27 views

wp query custom orderby not custom field

I am working on a products archive page where I show 20 products on each page with pagination. Each product's price is calculated by a formule which gets his parameters by data saved in the database. ...
0
votes
0answers
47 views

Function inside shortcode doesn't display WP_Query properly - custom post type

I have a problem with some shortcode and a function to display list of shops based on another shortcode. I wrote some code: Shortcode function shops_list($atts){ extract(shortcode_atts(array( ...
0
votes
0answers
22 views

How set offset on query with specific post_type from functions.php

I have a page template called 'page-blog.php'. On that page I have 2 queries that both obtain the posts of a different post type like so: $posts = ...
0
votes
0answers
17 views

Displaying Taxonomy titles with their post

Suppose i have a taxonomy note_navigation like this Class 11 --Science --> THis is children of Class 11 ----Physics --> Children of Science and grandchildren of Class 11 ------ QUantum Physics ...
0
votes
0answers
24 views

Display result from custom post meta query

This is driving me crazy! I'm trying to simply echo the contents of a meta field (twitter) from the wp_postmeta table of a custom post type with the following query outside of the loop : global ...
0
votes
0answers
42 views

Standard WP_Query Returns No Results

Edit: found the problem. The fields I'm trying to filter on are custom fields. They were created with the "Load value based on the post's terms and update the post's terms on save" setting UNchecked. ...
0
votes
0answers
18 views

Custom Query Problem

I want to get posts specified with just parent category, not with childs of it. But when I'm using category property, posts_per_page not working. If I remove category proerty, posts_per_page working. ...
0
votes
0answers
21 views

Filtering by custom fields select?

I have a custom template listing all the posts under a category x. This is how my current loop looks like: <?php query_posts('cat=522'); while (have_posts()) : the_post();?> All the ...
0
votes
0answers
29 views

Too many categories drastically slow down my website

I'm building a WordPress website that needs something like 7.000 categories. I added them, but now I have very long loading times. Pages need something like 30-40 seconds to load completely, and I'm ...
0
votes
0answers
14 views

How to use query on pre_get_comments?

I'm trying to make a search field for comments but when I try to modify the query in pre_get_comments nothing changes to the output. This same way IS working with pre_get_posts but for some reason I ...
0
votes
0answers
26 views

Ordering Posts by parent category, name ascending

I am currently creating a theme, and I have 2 parent categories: Budget and Brand. On home.php, I want to order all the posts ascending by their sub category name without showing the category title. ...