Questions tagged [query-posts]

Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

Filter by
Sorted by
Tagged with
0
votes
3answers
73 views

Posts are not looping through correctly

I am trying to make the page have 3 posts in each row, and then after 3 columns (12 posts) show the ajax load more button. Right now only one post is showing up. I don't know how to make it correctly ...
0
votes
1answer
139 views

Using functions.php to include code that's processed inline

I have a somewhat complicated WordPress template that keeps getting more complicated as the client wants it to work this way under one condition and another way under another condition, and so on and ...
1
vote
1answer
2k views

Exclude posts with empty post_content in wp_query

is it possible to exclude posts with empty post content from a wp_query? $args = array( 'post_type' => array('post'), 'posts_per_page' => 5, 'post_status' => 'publish', ); $...
1
vote
1answer
218 views

popular post weekly and monthly

i want to display popular posts for 1 week ago and 1 month ago.these are codes that i used but these don't work correctly for 1 week ago <ul> <?php $week = date('W'); $year = ...
-1
votes
1answer
2k views

Render a loop in Timber (twig for Wordpress)

I would like to render this loop in Timber. $query = get_posts(array('post_type' => 'lexique','posts_per_page' => -1)); $by_letter = array(); while( $query->have_posts() ) { $query->...
3
votes
1answer
11k views

Display Custom Post Type Fields

I'm making a website and want to display Events. Therefore I made a Custom Post Type called 'event'. I'm querying events to show them in a page. The Events I made also have some custom fields like : '...
0
votes
1answer
38 views

Seach and categories not working when ignoring sticky posts in main loop

My search does not work anymore, the same goes for my categories. It now shows literally all the posts until the page limit is reached, instead of the specified ones. This happened after I made sure ...
0
votes
0answers
130 views

posts_per_page increment additional post

<?php // the query to set the posts per page to 3 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'posts_per_page' => 3, '...
0
votes
0answers
237 views

Custom WP_query and integrating into theme file

I'm trying to use WP_query with a custom field to make one category of posts behave differently than the others; namely to 1) sort in ascending order by the custom date field (event_date) and 2) ...
1
vote
1answer
1k views

How to filter query to display posts from parent category only?

I'm using the Mini Loops plugin to display recent posts. When viewing a parent category it displays the posts from that category as well as any child categories. I would like to change this so only ...
0
votes
1answer
179 views

Can't change posts per page in WordPress Post Type Query

I have a custom post type called "Events". The post displays fine, except that the WP Query loop only displays one post instead of all of them. Here is the complete code from my functions.php file for ...
0
votes
2answers
2k views

wp_remote_post and form post

Actually it is more general question but now i am trying to use it on wordpress site so I preferred to post it here. I am trying to understand the difference between remote post and form post. When ...
0
votes
2answers
1k views

Filter date from post meta when date is in string format

I want to filter posts using dates stored in the post meta table. Here is an image that shows how the meta data is being stored: I want to filter records between the start date and end date. Here is ...
0
votes
1answer
220 views

Loop through custom taxanomy in post and display custom fields from posts

I will try to elaborate the title. I want to make a post, within this post I want to loop through all posts from a custom taxanomy and extract custom fields. How is this done in the most efficient ...
0
votes
1answer
78 views

Get next page in get_posts

I need to iterate posts list because I need to know how many posts I have in the specified category. When I do a get_posts I'm using posts_per_page => -1 but wordpress is still returning the same ...
0
votes
1answer
121 views

Pull posts from all categories if quantity is not met?

I have a modified theme that displays CPT posts. I am creating a slider that will cycle through all the sticky posts and display them at the top of the page. So far so good. The problem. When I ...
0
votes
1answer
109 views

Query_post 5 post first / last of post_id

i have list post id: 1 to 100 How to: In post_id=50 show list post_id=51,52,53,54,55 and list post_id=45,46,47,48,49 by category of post_id=50 Any idea for help me! Thanks
1
vote
0answers
121 views

Custom fields (wp_post_meta) vs Custom Table for large amount of data

This is already a common question but I didn't find an answer for my specific problem on my research, so here it is. I have a Custom Post Type that needs about 100 fields of data (these fields may be ...
0
votes
1answer
332 views

How to Create movie schedule by custom post type query

I want to create movie scheduler by custom post type query. That will display like: "Day 1, 15 oct 2016" 1.Movie list goes here 2.Movie list goes here "Day 2, 17 oct 2016" 1.Movie list goes here 2....
0
votes
1answer
128 views

Calling body_class and wp_nav_menu for a different post

I need to be able to display wp_nav_menu and body_class for a page/post that isn't the current post. For instance: // current page/post is ID:100 wp_query/query_posts{ // currently looping a ...
2
votes
2answers
89 views

Pass the same object to multiple widgets in a template with one query

I am currently looking into passing a single query into multiple widgets on a template without running multiple queries. The obvious goal is speed and efficiency. I have a widget that will deliver ...
0
votes
1answer
127 views

Query only title/field/featured media of posts [closed]

I'm going to develop a Wordpress plugin as a webesrvice for mobile application. How can I get only title/id/featured media of posts in wordpress plugins? I had a look at wordpress developer ...
0
votes
3answers
3k views

Post Loop not Returning Permalink

Somewhat of a weird problem: I have a post loop that display the three most recent posts from specific categories. It seems to work, except the post url is not being returned. It returns just the ...
2
votes
1answer
5k views

Inserting Post Using wp_insert_post. How to Fill Yoast Plugin SEO Fields

I am inserting posts into a database using wp_insert_post function once the post is inserted using below line of PHP $postId = wp_insert_post($array) I can insert values in my advanced custom fields ...
0
votes
2answers
424 views

Ordering Posts By Meta Data

I'm attempting to order posts by meta data, which is working fine, but the posts without the meta are not shown. I've tried a couple of guides on Stack Exchange that come up with a quick Google, of ...
0
votes
1answer
27 views

postsperpage value not being applied

I have a custom post type called laptop, and in my theme's front-page.php I have: $loop = new WP_Query( array( 'post_type' => 'laptop', 'postsperpage' => '30' ) ); if ( $loop->have_posts(...
2
votes
1answer
624 views

Exclude first 2 posts with meta_key from loop

I have 2 loops on a page. The first displaying 2 featured posts: <?php $args = array( 'posts_per_page' => '2', 'meta_query' => array( array( 'key' => '...
1
vote
1answer
992 views

Displaying the last post on static homepage

(It might not be the first time this question is asked, but every time I found someone else asking it elsewhere, the post was very old and the method used wasn't efficient anymore.) ► I'd like to be ...
0
votes
1answer
75 views

How to only fetch certain Tag ID's

I have this PHP script to fetch tags (as we use WordPress as a CMS, the tags are "categories" for our partners).... However, I'm trying to free up "tags" to be used on blog posts - but currently the ...
0
votes
2answers
222 views

Bootsrap carousel for post

I'm trying to have a Bootsrap carousel to display my post - They are being display, However, it doesn't work correctly. It doesn't slide basically.... Here is the live example: http://...
0
votes
1answer
756 views

Repeating post how to solve this

In home page it loads the more post correctly. But when i use the same code for loading more post in single.php (i.e article page), it not loading correctly. on the intial load it shows 3 post as per ...
-1
votes
2answers
208 views

How do I correctly query posts from a post ID?

Ok so I have this code to Query posts from a certain ID: <?php $valid_post_types = array ('agencies','pro-awards-winners','marcawards','topshops'); $args = array( '...
0
votes
1answer
354 views

Query posts only with actual text content (not including shortcode or images)

I'm trying to display a set of posts with the thumbnail, title, and content/excerpt. I don't want to show posts that don't have content or a thumbnail for display/formatting purposes since this is ...
0
votes
1answer
86 views

How do I get the posts from single page custom post type from a sidebar to display in a page?

I have a custom post type called storylist, which is done as a plugin for a sidebar widget.The custom post type story list compiles lists of other custom post types and displays them in the sidebar. ...
0
votes
1answer
47 views

Search: display all found matches inside post

I'm working on a custom search where I'm filtering results using custom taxonomies and categories. The search works but on the results I want to display every match inside the post, for example if I ...
0
votes
1answer
165 views

query_posts() doesn't seem to be called in my page

I've a problem with my query_posts() call. Here is my code: $results = $wpdb->get_results("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = 'mashsb_shares' ORDER BY CAST(meta_value ...
0
votes
1answer
38 views

Div Missing In Custom Loop Query

I'm using a customized php code for my wordpress loop. The code is designed the break the post up to be styled differently via html & css. The code is also designed so that I can add div blocks in ...
1
vote
1answer
2k views

Add class to first post in custom loop using post_class filter

I am trying to add a class to the first post in a custom WP_Query. I can add a class to the first post of the standard WordPress loop using; add_filter( 'post_class', 'featured_classes' ); function ...
0
votes
1answer
625 views

Filter posts by current date ( WP Post Carousel )

So i managed to filter the posts with this snippet : <?php echo " works"; $current_day = date('j'); $current_month = date('M'); query_posts('day='.$current_day.'&month='.$current_month); if ...
0
votes
1answer
42 views

Modify query to exclude certain ids and certain parents and its corresponding children

I'm trying to modify an admin query where I need to exclude a few pages based on two conditions: Exclude based on certain titles Exclude based on certain pages, including its children pages To ...
1
vote
1answer
491 views

Filtering out child category posts from parent category archive not working

In this example cat 5 is the parent category, and 42 is a sub-category. I the main category 5 archive I don't want any posts from sub-category 42 displaying. Why isn't this working? function ...
0
votes
1answer
27 views

Main site single-property.php design, as homepage of a multisite

I've been researching how to do this for some time now, and I'm coming up short. I have my main blog, example.com, which we've created a custom post type of Property. I'm needing the exact layout and ...
0
votes
1answer
7k views

How to get posts from a current post's month?

I want to display the titles of the post of the same month as the blog post. I tried this .. <?php $year = the_date('Y')?> <?php $month = the_date('M')?> <?php $theids = $wpdb-...
2
votes
1answer
67 views

Taxonomy.php issue with search and filters

I'm trying to create a custom taxonomy.php page where my users can refine search into that context. I've tried to create a kind of loop like: <?php if(!empty($_GET['ending'])) ...
1
vote
1answer
2k views

How to build a WP_Query using mulitple tags and using AND or OR operator between them

I'd like to craft a query to return posts based on the conditional presence of certain tags. The pseudo query is: return posts with "((tagA OR tagB) AND (tagX OR tagY))". But I'm having issues ...
0
votes
1answer
25 views

How to sort posts according to meta value?

How can I sort all the posts according to their meta value? I am using the below code: $args = array( 'meta_query' => array( array( 'key' => 'wpcf-stream', '...
0
votes
1answer
121 views

Sort Events by Venue Title - Sort Post set by related post ids

In wordpress, I am using The Events Calendar Plugin to host events. This includes two post types: events and venues. On an index page, I would like to list ALL events, but ordered by their ...
0
votes
1answer
4k views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
2
votes
2answers
2k views

_wp_page_template to dynamically use template

I'm wondering if it is at all possible to set display a page template chosen by the user within the context of a query_posts using get_template_part. In other words, I have set up a page template to ...
3
votes
3answers
130 views

Are there any scenarios where the query_posts may be used?

I feel there is a red button saying "Do not press" below query_posts(). For some time I am trying to demystify this phenomena with very low success to be honest. For example, probable the main ...

1
3 4
5
6 7
24