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

learn more… | top users | synonyms

1
vote
2answers
495 views

Order query by post meta value

//Displaying latest post per author on front page function filter_where($where = '') { global $wpdb; $where .= " AND vipwp_posts.id = (select id from {$wpdb->prefix}posts p2 where ...
1
vote
1answer
986 views

Display category posts grouped by taxonomy

I'm working on a project where I use the default posts as "Products", default category as "Application" and a custom taxonomy called "Groups". I want to list "Products" by "Application" ...
1
vote
1answer
259 views

Pull post meta with post_query?

I'm building a custom index loop that just uses query_posts at the moment. The issue is that inside The Loop, I have to then query for the post meta data (with get_post_meta), which I believe has ...
1
vote
3answers
3k views

$query->query_var['post_type'] not set for pages

Bulding off of this response from @kaiser about being able to filter by post types on a search page, I wanted to be able to automatically add-in all of the public post types available. So, after some ...
1
vote
1answer
123 views

Get the timout value of a saved transient?

Does anyone know if there is a Wordpress function to get the timeout value of a saved transient? I am using a transient with a 5 minute timeout to cache data from a web API call locally. Between ...
1
vote
2answers
546 views

Get the most popular terms for a custom post type

I’ve hit another small rock in my current project! I’m trying to list (and link) to the archive page for the top 4 most used terms for a custom post type. I have this; ...
1
vote
1answer
1k views

How to display posts under a specific subcategory of a given category

after a long search online I have decided to post my problem here in the hope of getting a solution to this issue. Well, I have a custom post with various categories (novels, books, magazines etc..) ...
1
vote
2answers
4k views

get post id using the $query_vars variable

How can I get the ID of a post (or page) based on the $query_vars variable? I want to do something like $query_vars['post_id'] But I don't have a reference page that has the list of $query_vars ...
1
vote
2answers
1k views

How do I search inside specific taxonomies in Wordpress

I am trying to search for posts in specific taxonomies but any time I search, I get results from all the other pages instead of Wordpress searching within the selected category in the taxonomy. I ...
1
vote
1answer
807 views

Wordpress Search Filter Only for Page with Child of Child of Child of Child of Child

after browsing question from this site I found the workaround for this: function SearchFilter($query) { if ($query->is_search) { global $post; $query->set( 'post_parent', 21 ...
1
vote
2answers
226 views

Tricky WP Query

I am trying to use wp_query (or another native Wordpress query class) to do the following: get all posts WHERE ( post_type = 'post' AND category = 7 ) OR ( post_type = 'case-studies' AND meta_key = ...
1
vote
2answers
479 views

Conditional custom field query

I'm working on a job board-type site, and the client want to sell featured posts. They want the featured posts to expire from showing up in the "featured" section after a predetermined period of time, ...
1
vote
1answer
150 views

Help with Wordpress Query

I'm sort of a noob when it comes to Wordpess; I've only recently started building themes and I've run into a wall. I'm trying to feature 3 different articles at the top of my site using wpquery and ...
1
vote
2answers
896 views

Can't pass table to $wpdb->prepare

I'm having trouble passing a table variable to $wpdb->prepare(); Here is functioning code: $table = $wpdb->get_blog_prefix( $blog_id ) . 'my_table'; $voters = ...
1
vote
1answer
505 views

Help with wordpress custom query and advanced custom fields plugin

first of all sorry for my bad english. Let me explain what I`m trying to do: I have a column inside a SQL table with a string using the following format: yy-mm-dd The thing is, it doesn`t use a ...
1
vote
1answer
176 views

Most effective use of DB querys

I've got a custom database table with lots of data that I'd like to query several times from a custom template file I've built. Say the db table looks like this: id name city zip 23 ...
1
vote
3answers
827 views

Possible to filter the posts or categories that XML-RPC users see in their mobile application?

Is it possible to filter the posts or categories that XML-RPC users see in their mobile application? I have a plugin that hooks into pre_get_posts and list_terms_exclusions to do what I need it to ...
1
vote
2answers
643 views

query_posts() ALWAYS displays something?

OK, I'm using posts_query() to display posts. The problem is, at least in my case, posts_query() always outputs something. For example: <?php $paged = (get_query_var('paged')) ? ...
1
vote
2answers
1k views

Count how many posts have a custom field set

I've added some code to my templates which automatically adds custom fields to cache some data that each post pulls in. Is there a way that I can track how many posts have had this custom field set?
1
vote
1answer
45 views

convert custom query to wp_query

My query is as below $querydetails = " SELECT wposts.* FROM $wpdb->posts wposts INNER JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id INNER JOIN ...
1
vote
1answer
21 views

Alter a specific query on Wordpress

I need to change a query of a plugin that is not the main query. The author did not put any filters. I can see the query from $wpdb->queries Is there a way to access the specific query and ...
1
vote
1answer
24 views

Custom query to get terms from post ids

I want to get the terms object by given posts ids. I don't know much about sql, and this kinda complicated for me. Here is what i tried: global $wpdb; $taxonomy = 'category' $term= ...
1
vote
1answer
61 views

List all posts from past week grouped by sub-category

On a category specific template, I want to list all the posts from the last 7 seven days for that single single category and group them by subcategory. This is the code I have so far, which lists the ...
1
vote
1answer
26 views

Custom Field Create Bulk via SQL Query

I have a question. A created a custom field named video_desc. I have ofer 2000 posts and I need to add this custom field to all posts and add the text "Description Here" to it. How can this be done ...
1
vote
1answer
154 views

How to get the posts published in last two days using WP_Query?

I am trying to loop through all the post to get the top most shared posts on social network. I want to use the date_query parameter in the WP_query to get the posts of last two days , last 5 days, ...
1
vote
2answers
75 views

Transient not working for custom loops

I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of ...
1
vote
1answer
36 views

Get IDs of posts currently visible on archive

This probably is a easy one for many. And also probably is already answered here, but I don't know how to search for it - so sorry I did search but not found anything. I like to get the contents of ...
1
vote
2answers
41 views

Query custom post type only if it contains another custom post type

I currently have a custom post type named "blog". On registration, every user gets automatically a post "blog" linked with their user ID. This custom post type queries another post type named ...
1
vote
1answer
171 views

Pagination with $_POST and $_SESSION

I have a page on my site where in the left column is a set of checkboxes representing taxonomies and in the right column is a list of posts that fall into the selected taxonomies. The user is able to ...
1
vote
1answer
144 views

Change media attachment author via mysql query

How does one bulk change the media attachment author via an sql query? I have hundreds of media attachments that need to be moved to another author so the original author can be deleted; but that ...
1
vote
1answer
165 views

example of build_query function?

I have this resource: (http://codex.wordpress.org/Function_Reference/build_query), but it does not give full example. I have this URL: mypage/?page_id=87 and this array: array('name' => 'me') ...
1
vote
2answers
82 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 ...
1
vote
1answer
189 views

How to go about combining dropdowns / filter queries?

I'm coming up short with my googling here. (As 'filter' in wordpress always turns up more content related info). Anyway, my situation is this: I have Categories, Tags, Authors and Archive dropdowns ...
1
vote
1answer
39 views

How Can I Query a Specific Page From a MultiPage paginated Post

Let's say I have a post that has been paginated by adding the <!-- nextpage --> code provided by wordpress for this purpose. How can I then query a specific page from inside of that post. ...
1
vote
2answers
597 views

Optional Meta Query

I have places stored as posts in WP's posts table. I am doing some geo-locating using Geo Data Store (http://wordpress.org/plugins/geo-data-store/). This is working great for me, as I can currently ...
1
vote
4answers
263 views

Add a class to posts in increments of 2

Is it possible to add specific classes to posts/pages in a query in increments of 2? For example Post 1 Post 2 Post 3 (add custom class) Post 4 (add custom class) Post 5 Post 6 Post 7 (add custom ...
1
vote
2answers
1k views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > ...
1
vote
1answer
202 views

using post__in allow duplicate post id

I have an array of ids in a specific order. I use post__in in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore ...
1
vote
2answers
174 views

Query reset problem or flawed code to enable custom post type query

After reading through here and trying various options, I am finally able to get my custom post types 'testimonial' (created with product 'Toolset') to show along with my standard cat/tag queries ...
1
vote
1answer
615 views

Get parse_query filter to return slug instead of id

After much headache in the last week I feel like my problem is almost solved. I have been attempting to customize the admin edit.php page of custom post types to display and sort/filter custom ...
1
vote
1answer
200 views

Add post_type to index.php

I search for an hour now without result. Does anyone can explain me how to show my custom post_type (dictionnaire) in the homepage (index.php). I use 'Easy post type' to add custom post types and I ...
1
vote
1answer
137 views

how would I create a custom query to get all users, and a related post based on a postmeta field?

I have about 50 users. Its pretty easy to list them all. However they are related to a special custom post type through a postmeta field called wpp_agents. So I need to list Users, but also the ...
1
vote
1answer
275 views

Get Metakey value while saving post

I am trying to insert metakey value while saving or updating post but somehow it is not inserting metavalue to link column of my custom talbe called wp_banner_views function ...
1
vote
1answer
80 views

Most liked page not displaying posts

I was looking for a post rating system for a while, then I stumbled across a great tutorial: http://wp.tutsplus.com/tutorials/how-to-create-a-simple-post-rating-system-with-wordpress-and-jquery/ I ...
1
vote
1answer
2k views

Use get_post_types to query only custom posts types

I need to query only custom posts types - that is all post types in my WP install excluding posts and pages. I have used get_post_types to build a string of all custom post types which I want to ...
1
vote
1answer
109 views

Sort query by author: 1 author, then others

I have a post type called 'article' and on the article archive page i'd like to show all the articles, sorted by author. function kia_adjust_the_query( $query ) { // change posts_per_page ...
1
vote
2answers
2k views

Help with MySQL to $WPDB query

Here's my issue. I have three tables I'd like to query - states, points, and state_points. States contains stateid, and name. Points: pointid, pointlat, pointlng. State_points: Stateid, Pointid. ...
1
vote
1answer
468 views

Append a value to a certain page's URL before page load

This particular website is using Tubepress to display a youtube video gallery. Now, Tubepress recommends that, to define which video goes to the front part of the gallery, we should append the id to ...
1
vote
2answers
101 views

Querying both pages and posts

I am building an "advent calendar" for a client and they are wanting a combination of specific pages and custom posts appearing on the front page, in a specific order. Things that need to be ...
1
vote
1answer
402 views

Exclude featured image and custom field from this get_attachment query

Is there a way I can exclude the post thumbnail AND a custom field with the value "_lm_comm_logo" from this query that pulls all of the images associated with a particular post? <?php $args = ...