Tagged Questions
2
votes
0answers
23 views
How to implement time filter to show random post 1 month for one category and 3 months for other categories
I started to work on one website after another developer and there is problem with his "popular widget" which is basically showing 3 random posts from category. There is some Switch statement which is ...
0
votes
0answers
20 views
Complex WP_Query Using Post Date And Post Meta
I am using Wordpress as a CMS on a website which has standard posts, a custom advert post type and a custom event post type. The event post type has some custom meta which stores the event start date.
...
0
votes
2answers
32 views
Set conditional on template based on referring page slug
I have a portion of a page template that is conditional upon the following elseif
<?php elseif( isset( $wp_query->query_vars['details'] ) && $wp_query->query_vars['details'] == ...
-2
votes
0answers
34 views
Get all posts starting with first two letters in Wordpress
I have a plugin in which an alphabetical list is posted where people can click on a letter and they get the posts with that letter. So if they click on A, they see all post titles starting with the ...
1
vote
1answer
35 views
Perform query with meta_value date
I am trying to perform a query on a custom-type post using the value of a custom field.
This field contains a string date: dd.mm.yyyy.
The post type name is 'event'
The custom field name is ...
0
votes
1answer
22 views
Query for first 3 posts to change the look and feel
Is there a way to query for the first three recent posts and then change how they display on the front page?
I want the first three posts of my blog to show differently than the rest of them i.e. ...
0
votes
1answer
54 views
Better wordpress attachment query then this
I have a site with more then 10.000 posts and images, its classipress site. I need somehow to show all images from posts that are on pending status, and who havent expired(post meta). This is the code ...
4
votes
1answer
183 views
Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
I've registered custom rewrite rules and query_vars to use for displaying a list of events based on ISO date format. For example when a user requests the URL, http://site.com/by-date/2013-04-04/, my ...
0
votes
1answer
29 views
Modify query after meta value
I would like to change the calendar so it will display some posts based on a custom date field. For now i am interested to modify this query:
$wpdb->get_results("SELECT ID, post_title, ...
0
votes
1answer
128 views
Upcoming Event: How do I sort database by custom date field, but ignore past dates?
I am using an events plugin and struggling to get my database query to be perfect. The query is on the event-single.php template. What I need the query to do:
Query the "events" custom post type ...
0
votes
1answer
136 views
Custom post types loop on a page template
Hi I'm trying to make a page template that shows a list of a custom post type ordered by a meta key, I easily made it with query_posts but I am trying to do it via pre_get_posts so I made a function ...
0
votes
1answer
67 views
Query custom posts from custom taxonomy
I'm trying to do a custo slideshow, but I have problems with query the posts.
I have defined a custom post type "slider" and a custom taxonomy "slideshow":
custom post type:
function ...
0
votes
1answer
42 views
WP_Query: query posts by ids from array?
I did quite a bit of research but can't figure why this wouldn't work for me?
echo print_r($rel); // Array ( [0] => 63 [1] => 87 )
$args = array(
'post_type' => array( 'post' ),
...
0
votes
1answer
198 views
How to query a custom post type with a taxonomy filter but display post type archive page?
I'm filtering the main query of Jigoshop with my own taxonomy with this hook (The file responsible for Jigoshop queries that I'm hooking, Jigoshop hooks onto WP 'request' filter):
add_filter( ...
0
votes
2answers
192 views
Setting get_queried_object
I know that get_queried_object contains the object that was queried for the current page. My question is, what methods of querying affect the contents of this?
For instance:
query_posts
get_posts
...
3
votes
1answer
73 views
How to query for a week using key => value WP_Query argument notation?
I would like to be able to query for a specific year and week using WP_Query argument notation. I am using this notation as I would like the page to paginate.
What's the correct "year" and "week" ...
2
votes
1answer
325 views
Page navigation doesn't show when query category
Problem:
when I do www.example.com?cat=4 or choose category through custom menu or from category widget it shows only first page without navigation at the bottom, where it supposed to be. It's the ...
0
votes
1answer
84 views
WP_Query ordered by custom field that is a date string?
Each of my posts have a single custom field that is a string of a date (not the date of the post). Instead of my theme's current query, which orders by published date, I want to order by this custom ...
0
votes
1answer
98 views
Why posts array is empty?
I try to get posts that either do not have a custom field set or if set have a value not like a given parameter.
Here is my code:
$args_included = array(
'numberposts' => 1,
...
0
votes
1answer
189 views
WP_Query meta compare must include ALL array values
I am allowing users to query posts using a form with checkboxes. I want the posts to be filtered by the checkboxes but instead of showing all posts that include the ANY of the meta values selected I ...
0
votes
1answer
46 views
Get WP_Query query after execution?
It it possible to get the configuration of a the latest called WP_Query? I need to use it for debugging.
For example, if i run something like:
$the_query = new WP_Query( $args );
...
Could i get ...
2
votes
1answer
99 views
List the 5 most recent child pages
I created a hierarchical custom post type for a gallery. The parent pages are the galleries and the child pages are the albums. I want to display the most recent albums on my sidebar (so basically the ...
0
votes
3answers
96 views
How to check the array values, what WP_Query has brought to me?
I have two questions in a row:
How to check the array values, what WP_Query has brought to me?
If I get 10 posts in cat=3, then I want to get only 5 from them, and then want to echo them ...
0
votes
1answer
279 views
posts_per_page doesnt work
Here is the my custom query ;
<?php
$Poz = new WP_Query(array(
'posts_per_page' => 3,
'orderby' => 'date',
...
0
votes
1answer
37 views
Showing posts from 4 categories along with all latest posts
Currently in my theme i am running the default query that pulls all recent posts/latest entries/latest published posts . But i am looking for something more complex like i am gonna setup two sections ...
1
vote
1answer
196 views
WP_Query Performance Issues with meta_query
I'm working on a custom template for a new theme that uses a WP_Query instance to select posts from 2 post types with 2 custom fields that are NOT empty. Depending on the section of the site, a ...
1
vote
1answer
88 views
Is there a reason why Pages are not publicly_queryable?
I am building a segmented search (by post type) with the ability to filter to a specific post type and realized pages were not publicly queryable. What I know I can do is the following:
function ...
2
votes
2answers
196 views
Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.).
I'm ...
0
votes
1answer
127 views
Start Query from 2nd Post without offset
is there a quick and easy way to load all the posts, starting with the second post and making the first post the last post? If I use offset, I then lose the first post, but I don't want to lose it, I ...
0
votes
1answer
980 views
Get the number of rows from $wpdb->get_results not working
I want to count the number of rows of this custom wordpress query and it does not work:
*PS I am accessing a custom table inside my wordpress database, mabe by myself. The $wpdb->get_results part ...
2
votes
1answer
710 views
WP_Query vs get_posts
I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
1
vote
1answer
77 views
Query Page Content From Theme Options?
I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme
That lists the pages in ...
1
vote
1answer
92 views
posts_per_page option limits the number of Gallery items
I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
0
votes
2answers
224 views
Exclude some authors from query
This script list users with their last post. How to exclude some authors from guery ?
<?php
//List of users sorted descending by date of lastest post written by user
$uc=array();
...
0
votes
2answers
193 views
shortcode using multiple WP_Query's with multiple category names not fully functional
we're working on a bilingual site,
Larry A. Downs
all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories,
i've ...
0
votes
2answers
127 views
Transient api Caches confused
This code works for page 1
<?php
$paged1 = (get_query_var('paged')) ? get_query_var('paged') : 1;
$recent1 = get_transient( 'recent1' );
if ...
1
vote
1answer
496 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 ...
0
votes
1answer
103 views
Pagination in wp query with transient api
I have intergrated wordpress transient system with w3 total cache. Now i can`t to do pagination for this query.
<?php
$paged1 = ...
1
vote
1answer
76 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 ...
0
votes
1answer
150 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 ...
0
votes
2answers
133 views
Parsing External Table Arguments
I have a client project that has posts assigned to their country of origin.
The client wants to be able to search the posts by continent and or region.
I have a separate table that assigns each ...
0
votes
2answers
197 views
Disable (or limit) queries when certain content (or data) is not needed (or showed)
Currently I am making a custom design for a site. The problem I'm seeing in Wordpress is about almost all data pulled out from the database.
While in certain pages - like front-page.php - it only ...
0
votes
1answer
428 views
How to Loop within a Loop (Display Children and then Grandchildren)
I am trying to develop a query for WordPress that will allow me to display a list of child pages with titles only, and then under each child page title, a list of grandchilden (children of the child) ...
1
vote
2answers
105 views
Query last updated posts (posts updated in the last 24 hours)
I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours.
My idea is to have a page of posts or perhaps on the index.php a lists of ...
0
votes
1answer
69 views
Retrieve or Query Pages by ID
I have a problem with my code, I want to display 3 specific pages on my homepage but my code is not working.. here's the code..
<?php $args = array(
'post_type' => ...
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
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 ...
0
votes
1answer
50 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
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
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 ...
