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

learn more… | top users | synonyms

4
votes
3answers
314 views

Query custom post type by custom field

General Info I used the plugin WP Types (wp-types.com) to create a custom post type called "artist". In WP Types you can also set another post type as parent post type. This is not possible by ...
0
votes
1answer
60 views

get_var result empty for query of custom table in plugin admin

(There are a lot of related questions to this but none I can find with answers that have worked.) get_var returns empty when I query a custom table from a custom plugin for multisite. What am I ...
0
votes
2answers
70 views

Get a list of posts by specific category

I'm trying to build a search query in PHP in WordPress and I need to get all posts by a specific author in a specific category including drafts. For example, is it possible to do something like, ...
0
votes
2answers
82 views

List of child custom post types lists all custom post types

Several of my pages have some "posts" of custom post types as child posts. On these pages I want to list all of the child posts. Therefore I have this code: <?php $page_id = ...
0
votes
3answers
98 views

Is_single() conditional tag returns null in query

Trying to figure out why this won't work for me. I'm simply trying to run a loop of all posts and pages, and tag them as post and page in a array. But the is_single() conditional is not working, all ...
4
votes
1answer
234 views

is_category() in pre_get_posts strange error

I have a function that sets posts_per_page option depending on the category viewed. I discovered and error which I can't really understand: first this is how I get the error: function ...
1
vote
0answers
41 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 ...
0
votes
2answers
149 views

Should $found_posts be returned as string in 'found_posts' filter hook?

In general a function that hooks into the found_posts filter looks like this: add_filter( 'found_posts', 'adjust_offset_pagination', 10, 2 ); function adjust_offset_pagination( $found_posts, $query ) ...
0
votes
1answer
102 views

Run again current query via ajax but changing a var

I have custom query which is $query. The input is based on form input. The query has already run on a page, but after that I'd like to run it again without a page reload, so with AJAX (when the users ...
1
vote
2answers
33 views

Exclude the first 'n' number of posts of a tag from home page?

Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query. I don't want the ...
0
votes
1answer
32 views

Arrange Category post manually when displayed

Is there way to display the category post manually or in a specific order. Basically the post are arranged in alphabetical order. It is a clients request Here is the code for category post ...
0
votes
1answer
143 views

Using in 'category_name' in '$query->set();'?

Here's the function I have in my theme's functions.php: function better_editions( $query ) { // Categories act as 'Editions' on my site $get_edition = get_query_var( 'category_name' ); ...
0
votes
2answers
245 views

When/why does '$query->get( 'tax_query' );' return empty?

First the code: function itsme_better_editions( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( 'post_type', array( 'post' ) ); ...
0
votes
1answer
133 views

Query set using tax_query with relation 'OR' modifies category object?

(Update: Please see the edits far below.) The code: function itsme_better_editions( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ...
0
votes
1answer
129 views

Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY – A post beginning with a – Because I want to be ...
0
votes
1answer
174 views

Fatal error Call to a member function insert() on a non-object [closed]

I am running Custom Query on functions.php: function subscribers(){ if(isset($_POST["email"])){ $email = $_POST["email"]; echo $wpdb->insert($wpdb->easymail_subscribers, ...
-2
votes
1answer
163 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 ...
0
votes
1answer
123 views

Order by title - but now built in wordpress func, sort the_title

I've got a pretty simple WP installation, where I use qtranslate plugin to keep site in two languages. The problem is, I need to sort posts by title, and as probably you know (as you use qtranslate), ...
0
votes
1answer
72 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
0answers
62 views

Sort post by category using HTML Select tag

Good day wordpress dev. Just want to ask if it is possible to sort, filter or query post using HTML Select tag? This is the design I am trying to develop. ...
0
votes
1answer
57 views

How to query post ids liked by the Author

I'm using wti_like plugin and this is how i get the number(count) of post liked by the author // Get the author object $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // Get the ...
1
vote
2answers
61 views

Optimizing Query used for a Shortcode

So, I have this shortcode that produces a list of all published multisite and their pages. The network in question has about 50 sites in it. The problem is that loading the page I put the shortcode on ...
0
votes
1answer
160 views

Show a 404 error page if Public query variable's value doesn't exist?

Public query vars are those available and usable via a direct URL query. On my site, I've created some custom URLs with their own query variables like so: ...
1
vote
2answers
67 views

is_archive() doesn't work on public query var archive pages?

Public query vars are those available and usable via a direct URL query. E.g. example.net/?category_name=tech&tag=gadgets But doesn't example.net/?category_name=tech&tag=gadgets show ...
0
votes
2answers
41 views

How to display lastest post date in the homepage?

I'm looking forward to display, somewhere in the homepage of a WP site, a legend saying: Last updated: XX/XX by grabbing the date from the most recent post, but not showing any of its content, ...
0
votes
1answer
141 views

how to access the $query variable inside taxonomy-xxx.php template file?

In my custom template files, I create query in the following way: <?php $query = new WP_Query(array('post_type' => 'aya-bi-aya','author' => $current_user->ID,'paged' => $paged, ...
0
votes
3answers
37 views

Include one page/post into query which is already returning posts

I have my news query which is on my index file. I want to include a post into this query which is infact a page. Is there anyway to do this? <?php query_posts(array( 'posts_per_page' => ...
2
votes
1answer
157 views

Save default value for empty or missing post meta

I am using WordPress and I am using a custom field that has the name ecpt_carprice for each post I am publishing, the field is saved in wp_postmeta the same as the attached image: Some of my cars ...
0
votes
3answers
241 views

Get wp_get_attachment_url outside of loop

I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able ...
0
votes
1answer
41 views

I am officially missing something about transient posts

I have no issue creating transients. What I have an issue with is pagination - and I have made posts on it before and every one sates that the query must look like, for example: $queried_post ...
0
votes
0answers
28 views

Multilingual Wordpress page - using URL to determine language?

I want to create a webpage that supports more than one language, but I don't want to use a plugin for that if it's possible. I am already loading the theme translation depending on the URL; if ...
0
votes
1answer
35 views

Category slug in in loop always the same?

My post category structure is 3-level deep: Products Milk products Milk Chocolate Cheese I want to show all posts from "Milk products" and add appropriate category slug as class, for example ...
0
votes
1answer
101 views

How to store post rating system data post independent?

There's code below for simple post rating system (tutorial from this site TUTORIAL ) - it works fine but i need to change it a bit. Now where user votes, he is not able to vote again for same post for ...
0
votes
1answer
37 views

search meta field for a value in all posts

Hi I want to search meta field for a value in all posts. Code below shows what i want to accomplish (im wp and php beginner and cant manage to make it work by myself). If in meta field "voted_IP" ...
4
votes
1answer
2k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
0
votes
1answer
140 views

Select column name dynamically mySQL Query

$country="USA"; $dr=$wpdb->get_results("SELECT $country FROM wp_shipping WHERE ID=$ids"); I want the above query in WordPress file, where country name is given dynamically but I am not getting ...
0
votes
0answers
16 views

WP_Query by date not working? [duplicate]

I'm using a function that returns posts using shortcode. My 'featured posts' are to be any category with the highest comments and only for the week. I have looked over the documents and even did a ...
0
votes
1answer
37 views

Query pages based on tags

On a site that I'm working on I've added the ability to tag pages. These tags should then be used in a query to retrieve all associated pages of a tag. In my functions file - // Add tag support to ...
0
votes
0answers
70 views

Join two wp_query

So, i have custom posts with this settings: Example 1: have meta_key "price" Example 2: have meta_key "no_price" So, i want to list this posts ordered by "price". I just want to join these two wp ...
0
votes
1answer
150 views

Insert images into wordpress post with a query

I have a Wordpress installation with 2.000 posts. Also in a separate table of my database I have a set of image paths and the filenames of the images, each image is assigned to each post of my ...
1
vote
2answers
45 views

Querying Term Posts in Loop

I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine: <?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' ...
0
votes
1answer
58 views

Filter posts by author selected in page

I've inherited a Wordpress project, and my client has a new feature request. For a "portfolio" page template, they want to be able to select an author, which I want to add to the $args in my ...
0
votes
0answers
20 views

Can I get parent taxonomy name from term in advanced search plugin?

I am currently trying to advance a plugin that basically creates a form where you add your own required types of data that you would want to be searched. In my form I have a taxonomy and I want to ...
0
votes
1answer
59 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
1
vote
1answer
60 views

if/else on custom query gives 200 OK when condition not met?

What? I am modifying my theme to show comments of a post on a separate page. How? Mostly based on this answer but with improved checks and code. So this is what my page-comments.php (kinda) looks ...
2
votes
1answer
114 views

Using Wordpress public query variables

Good morning. I am trying to query various Wordpress pages, using public query variables, for example http://dmkim1979.ru/?p=37 // single post http://dmkim1979.ru/?page_id=40 ...
1
vote
1answer
23 views

How can I get a list of comments by target

I've been looking at the classes WP_Comment_Query and WP_Meta_Query but to be honest, I can't figure out how to use them together. I want to query the database for comments where wp_posts::post_author ...
0
votes
1answer
343 views

date_query seems to be ignored by wp_query

I'm altering my main wp_query in a pre_get_posts filter in order to improve my site search capabilities. I've successfully achieved searching in taxonomies, but I fail when it comes to the post date ...
0
votes
1answer
90 views

Making certain categories of CPT not publicly queryable

I am developing a custom CMS for a client and one of the Custom Post Types is 'contact', these contacts are organized into categories by a custom taxonomy; my question is whether there is a way to set ...
1
vote
2answers
169 views

Sticky post appears twice

I am trying to modify the number of posts_per_page in the loop. This way: function posts_per_page($query) { $query->query_vars['posts_per_page'] = 3; } add_filter('pre_get_posts', ...