A generic term referring to the process of retrieving information from a database.
1
vote
1answer
1k views
How to query for most viewed posts and show top 5
Here is how I am getting the views for one post:
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
...
0
votes
2answers
263 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
votes
2answers
58 views
Wordpress Unknown Query
I have the following query and i can't find where is executed
SELECT count(ID) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY ...
1
vote
2answers
3k views
Get Featured Image via direct sql query
I know you can use the wordpress methods for getting a featured image, however with this particular project I need to get the featured image via mysql query. Can anyone point me in the right ...
0
votes
1answer
105 views
How to reference same column name but different table in custom db query
I use wpdb to connect to a custom db, then I use the following query:
$my_row = $wpdb_c->get_results("SELECT Employee.Name, Area.Name, Area.Region FROM Area INNER JOIN Employee ON Area.ID = ...
0
votes
1answer
344 views
Is it possible to create a shortcode that will query a post based on taxonomies?
I am working on a site that will be listing a few hundred products and we wanted to be able to quickly/easily show specific products on a page based on taxonomies. I have been doing some research and ...
2
votes
3answers
319 views
Reversing the order of posts AFTER the query is performed
I'm am displaying the last 5 posts of a custom post type 'show'.
This gives me the latest post first.
<?php
$args = array(
'post_type' => 'show',
'posts_per_page' => 5,
'order' ...
2
votes
2answers
1k views
Get category slug and display it on a query_post
I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories .
there is two parts to my question
- Part A - Get category slug and ...
1
vote
2answers
744 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.
...
2
votes
2answers
227 views
Get a user's most recent post title
If I have a user's ID, what's the best way for me to get the title of that user's most recent post?
0
votes
1answer
205 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 ...
0
votes
1answer
108 views
wp remove query
i want to remove a certain query in wp 3.1
add_filter( 'query', 'remove_delete_7_day_draft_queries' );
function remove_delete_7_day_draft_queries( $query ) {
global $wpdb;
$q = "SELECT ID ...
0
votes
2answers
715 views
Exclude category from query
PROBLEM
Hey everyone I have the wp loop to display posts, but I need to exclude category 81.
I tried: query_posts('cat=-81'); ?> before the loop but the pagenavi is broken and it doesn't work ...
0
votes
1answer
49 views
How to query for posts with either one or another custom field
Need help querying for posts with either one or another custom field.
Not sure how to use the 'or' operator here, but something like this the blow -
Have tried these:
...
0
votes
1answer
412 views
How to query term_id of a Custom Taxonomy by name
I have created a custom taxonomy "Birthday" within which i have created various dates like "December-12", "April-15"
How to get the term_id of the "December-12" by a query.
Thanks.
0
votes
1answer
448 views
mySQL query. ORDER BY meta_key
I'm fighting this quite long already and start to think I'm missing something big. CPT posts could have or not metadata ( _vip_post [0|1], _thumbnail_id [null|numeric] ).
If i query for ...
0
votes
2answers
54 views
plugin code is pulling information from database in one instance and not in other. What is wrong?
In my plugin code, I am pulling the table id from two tables. The id is being pulled from one table but not from the other and I get errors in both instances. The queries work on mysql when I use ...
0
votes
1answer
238 views
How to Check if a Child Category is Being Queried
I need to change the number of posts queried for specific categories 'Recipes' or 'Product Reviews'. The below code works great for this, I have it in functions.php:
function ...
0
votes
1answer
215 views
Trying to use WP_Query to return post with and without meta values
I am trying to return posts that contain meta value and ones that don't in one query. Is this possible?
So in plain English, I am trying to get posts that have a meta key of date and value of date ...
0
votes
1answer
222 views
Custom Post Type Query issue
I have a conflict issue with 2 custom post types. I have a template file archive-media.php and have created the related 'media' custom post type. This all works well, however in the sidebar I have a ...
0
votes
1answer
128 views
How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
I need to know the most efficient method to grab 3 pieces of data from from multiple posts:
Post title
Thumbnail
Custom Field
I am attempting to build a Google map of posts using data stored in WP ...
0
votes
1answer
70 views
Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
I´m building a real estate site where Estates is a custom post type. I want to be able to tick a checkbox or something similare on the edit page, where I can choose if the estate is for rent, if it ...
0
votes
1answer
189 views
Remove posts from query for events whose start date has passed
The query below works as expected, showing cpt event ordered by meta_value, what I haven't figured out yet is how to remove posts for past events or events which have started. The start date for ...
0
votes
3answers
180 views
Retrieving custom field array value through db query
I'm trying to query the database for posts based on multiple custom fields. This is easy enough with the code below if values are simple:
$querydetails = "
SELECT wposts.*
FROM ...
1
vote
1answer
405 views
Query get post,how to add comment box
Hello I have a query that gets a post with id=x and it works but it leaves out the comment box.
Is there a way to add "get comment box" to the query?
<?php
$post_id = 104;
$queried_post = ...
0
votes
1answer
197 views
Query posts and filter at query time by value of custom meta
I have a wordpress query for a custom post type, but I want to filter the results depending on the value of a custom meta.
<?php $my_query = new ...
1
vote
1answer
535 views
Show only oldest post by author
I am working with a heavily customized install of WP. I've set up a specific post type, taxonomy, and roles that gets to use just that post type.
Ideally, I'd like to restrict members of that role ...
3
votes
2answers
879 views
Create pagination and order according to alphabet
is it possible to create an alphabet pagination? as well as alphabet order of a query post???
I can't a solution on this based on the regular queries.
I would appreciate any help, thanks in ...
1
vote
2answers
902 views
Count user posts by user ID, Post type and Post status
What I am trying to do is modification of this function on codex http://codex.wordpress.org/Function_Reference/count_user_posts Check the title adding post type support bottom of the page. The ...
0
votes
1answer
255 views
Trying to put an array into 'post__in' => array() query not working
Slight problem, I have the following code:
$purchaseprodid = $_GET['ids'];
$args = array(
'post_type' => 'prizes',
'post__in' => array($purchaseprodid)
...
0
votes
1answer
305 views
Custom Query: query by post custom meta data
So I have a custom post called event, but I need to query only those posts which have a custom metabox(is a checkbox) called `Show On The Homepage: and only if that checkbox is checked.
<?php
...
3
votes
1answer
972 views
restrict_manage_posts not working in 3.3.1
I have noticed my custom taxonomy filters no longer work in the 3.3.1 admin as per these methods:
Adding a Taxonomy Filter to Admin List for a Custom Post Type?
I also discovered that to filter a ...
0
votes
1answer
310 views
Get array of posts based on custom field values
I'm looking to pull up an array of posts based on custom field values:
function GetPrimaryLinks($product){
echo '<ul>';
$args = array(
'product' => $product,
...
1
vote
2answers
291 views
Query from a different database than the default
I'm making a layout for a wordpress page.
The layout needs to connect to a second database (both databases are in the same domain).
But the problem is, when i execute just the file it works. But ...
0
votes
1answer
307 views
Get Child Custom Post Content on Single.php?
I have a custom post type, with children 2 rows deep...
Outfit 1
Inner
Child 1
Child 1
Child 1
Child 1
Outfit 2
Inner
Child 1
Child 1
Child 1
...
0
votes
2answers
393 views
Wordpress loop: Display <div> if posts exist
In a single post template I am trying to output some header text in a <div> and display links to related posts in a <ul> if related posts exist (based on tags). If there are no posts, ...
0
votes
1answer
112 views
Trim posts from WP-Query?
I wish to show in my front page a number of posts determined by the following criteria: show all posts from current month (actually from the month corresponding to the most recent post) ; but if that ...
0
votes
2answers
529 views
Get Posts from Last 24 hours and Sort them via GD Star Rating
I am trying to sort the posts using GD Star Rating in the last 24 hours. I have two separate queries, but I don't know how to merge them.
function filter_where($where = '') {
...
0
votes
3answers
614 views
Where is the query in wp-login.php
I am making a login form in WordPress and i want to have a validation on it, so i tried to look at the wp-login.php to see how they validate things. But i did not find what i am looking for. I would ...
1
vote
2answers
160 views
What is considered a default query for the request filter?
As stated in one of the answers in this question and in the codex entry for the request filter, said filter gets called only in a default query, such as the main query used for a loop. My question ...
0
votes
1answer
173 views
How properly create a blog template for wordpress?
I imagined that it is pretty easy to do: just take everything what is in index.php. Add
<?php
/*
Template Name: Blog
*/
?>
at the top and you all set, but in my case it is not working. I ...
0
votes
1answer
54 views
difference between methods of query
Looking in other plugins/widgets code , I usually see TWO different methods for a query :
one would be :
$args = array( 'numberposts' => $limit , // or, 1, or 20 ...
'exclude' ...
0
votes
1answer
162 views
Run query_posts if SESSION is empty?
I am having trouble running query_posts when my page loads for the first time, i.e Session is empty.
When the page loads for the first time and the SESSION is empty, the following code runs:
...
0
votes
1answer
120 views
Can't seem to do combined query AND sort?
Below is the code I'm using to query multi-day events. The problem I'm having is that I can either sort by the start date (evstart_date) OR I can do a combined query against start date and end date ...
0
votes
1answer
165 views
Order posts by recent comments
Guys I'm dying to find an answer to this problem, I need the wp query to order by recent comments so I can output posts that have recently been commented on (I'm trying to get something like a Recent ...
0
votes
1answer
56 views
Retrieve all term IDs of post
I have an array of term IDs that I'd like to filter my query with, but most wordpress functions seem to need the 'taxonomy' field entered too. Is there a reason for this?
Passing the taxonomy ID ...
0
votes
2answers
268 views
How to extract all ID variables from a query string?
What is the best php method to extract all IDs from a query string and display them in a comma separated list?
I have a function that grabs specific posts from the database and am trying to enter ...
1
vote
2answers
86 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 ...
0
votes
1answer
150 views
$paged always 0 on plugin's custom page
I'm making a plugin that loads a specific template depending on a certain query var being passed, in effect creating a page for the plugin on the front end, as outlined in this post:
Create a page ...
3
votes
4answers
5k views
Query multiple meta key values?
How to query for mutiple meta key values with the same key
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE ...