The core of the WordPress query, the loop offers an easy way to access post information and display it on your website.

learn more… | top users | synonyms (3)

0
votes
3answers
34 views

Check if loop has any categories?

In my loop, I have ten posts with the following categories (slug): group-a, group-a-first and group-b. The loop/query looks like this: Post (group-a) Post (group-b) Post (group-a-first) What's the ...
0
votes
1answer
16 views

Is wp_reset_postdata() redundant after the main loop?

I'm confused about an example from the docs: <?php // The main query. if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); ...
0
votes
0answers
17 views

ACF for loop only iterating once

Hi there I am attempting to output stuff based on an ACF drop down selection. I am using a for loop to output but it only iterates once and outputs the "1_col" part. Also the "component_button" part ...
0
votes
0answers
17 views

Adding a term to a listing inside of shortcode that otherwise contains permalinks to custom post items with custom field values

I have this shortcode to output all items of custom post type "song", on a page listing all the songs a musician released throughout his career. // Custom shortcode, to query tracklistings on the ...
1
vote
2answers
31 views

Loop and Page template : my WP_query don't take args

I have a problem with a loop that I try to put into a custom Page template. I would like to display posts with conditions, but whatever I put in my WP_query parameters, it is not taking in ...
-1
votes
0answers
31 views

Where to place script in while loop

I'm currently working on a grid template for a WordPress Custom Post Type loop. Basically I'm showing a video cover and when the user is clicking the cover a Modal opens with video and more opens. ...
0
votes
1answer
95 views

Merging a complex query with post_rewind and splitting posts into two columns

I need help with my query that uses rewind_posts so that if a post is in a particular category, it moves to the top. What I would like to do is have a query that splits posts into a two-column page (...
0
votes
1answer
25 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
20 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 ...
0
votes
2answers
39 views

Assign custom parameter to each post in query

I'm trying to add an incremental variable to each post that comes up in a series of queries. The purpose is to calculate a weight for each result in order to be able to order everything later. This ...
0
votes
1answer
414 views

add bootstrap post slider with tabs

I'm trying to add a carousel with my post. UNder the carousel, some tabs with the post title. On click of the post title, it should change it the slide to display the related post. In " Static" in ...
1
vote
2answers
323 views

Display custom post on home page based on a metabox selection

I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection ...
1
vote
3answers
566 views

Custom taxonomy template loop

I know that this question is asked numerous but i din't find an answer that suits to me. Well i'm made some custom post types and some custom taxonomies. I have the custom post type Products and ...
0
votes
1answer
15 views

Popular posts with Varnish ESI

I am trying to get Varnish ESI to work with displaying the most viewed posts on a new blog I am working on. Here is my current script; In theme file: <esi:remove> <?php get_template_part( '...
0
votes
0answers
28 views

Own class in while post loop

I've created my own class which I load trough my functions.php For my custom post type, I've created an own archive-{posttype}.php. In my while loop I'm trying to access $obj->functionName(), but ...
0
votes
3answers
168 views

separate the post of a category by subcategory

I'm dynamically generating my category post by getting the Page title and match it with the category name. The category I'm posting sometimes has a subcategory now I need to separate this subcategory ...
1
vote
2answers
60 views

How to handle “the_terms” inside loop

I have been searching google but I am really confused. I am trying to display the terms of the taxonomy assigned to the post. I am using the_terms($post->ID, 'locations');. The custom taxonomy is ...
0
votes
0answers
19 views

Converting fake php page loop to wordpress loop?

I was handed off a project that was created using backbone.js to be "WordPressified" and I'm having trouble converting the fake page loop in to a standard WP loop. When I first took this project on, ...
0
votes
1answer
553 views

the_content() “crashes” for single pages

I have big trouble with the_content() for single.php. Whats my problem? the_content() doesn't give any output on single pages furthermore it crashes (no other PHP code below the function call is ...
0
votes
1answer
15 views

Wordpress query posts by custom post type not workng

I'm trying to display the featured images of my custom post type of 'instrument' I created the custom post type using the plugin 'Custom Post Type UI' The query seems to work, but the problem is ...
0
votes
1answer
424 views

Loop and add Specific Categories and Products Images

Thanks to Rafael Marques, I have a list of Products and Categories organized based on different created categories. I also have 5 different Custom Page Templates. Now I would like to display the ...
-1
votes
3answers
649 views

Order by a meta field in query loop

I would like to sort my article from a category by a number added in a meta field. Here is the first step, I get the articles to display on the page. <?php $cat = get_post_meta( get_the_ID(), ...
1
vote
1answer
3k views

ajax for filtering posts by category in wordpress loops

I've been looking around for a way to filter my posts on http://www.waziproject.com/wazimagazine/ without reloading the page. So my question is if anyone can help me out to turn the following into a ...
-1
votes
1answer
36 views

How do grab the main loop, with conditions, and output via shortcodes

I don't have any code for this because I'm not sure how to begin. I created a category called "News". On my homepage I want to show the 3 most recent articles, but I need to output them using a ...
0
votes
0answers
16 views

can I separate two taxonomy (category) loops on one page

I have created a staff and teachers page with custom posts and categories. I currently have them display in an archive-teachers-and-staff.php template with no filter. I am using the date to get the ...
-1
votes
0answers
30 views

Shuffling Posts On First Load?

I have a category with 20 posts and I would like to shuffle the posts on the page for each individual user that visits the blog. I don't want the posts to constantly change order on reload, so what ...
0
votes
2answers
40 views

Conditional in foreach loop is outputting content twice

I have a website that displays a slideshow using custom fields and the Slick carousel, using the code below. <?php $entries = get_post_meta( get_the_ID(), '_mysite_homepage_slider_group', ...
1
vote
2answers
8k views

Display featured products through custom loop in woocommerce on template page

I was wondering if someone could help me out. I would like to display 6 featured products from my woocommerce store on my home-page.php template. After some researched I found that the right way to do ...
0
votes
1answer
35 views

Add post class in custom loop (WP_QUERY)

Normally if I wanted to add a custom post class I would use the post_class filter. However, when using a custom loop the post_class filter is not accessible. I am trying to apply classes that will ...
-3
votes
1answer
43 views

Group posts by year in loop

How can I separate posts by year in archive page for Custom Post Type? while ( have_posts() ) : the_post(); the_title(); the_post_thumbnail('thumb'); endwhile; The end result would look ...
0
votes
0answers
24 views

Creating a wordpress loop with featured images in different divs

I'd like to create a wordpress loop that allows me to style each featured images in separate divs. I've done a fair bit of research but can't seem to find anything that helps. Can anyone point me in ...
0
votes
1answer
13 views

Display Authors in a grid loop

I currently have the following php code which gives me a list of all the current WordPress authors, including their name and avatar. <?php printf('<h1>%s</h1>', the_title()); ...
0
votes
1answer
12 views

Wordpress query with items from more than one selfdefined taxonomy as `term` argument

So I'm working with a bought version of a plugin (WP Catalogue, sorry I can't post more links than 2) as basis for my code for a website i'm working on and i'm adjusting it so that it can be used for ...
0
votes
1answer
532 views

Admin login not working, because: wp-admin%2F&reauth=1 redirect

I want to login my WordPress site, but i can' because the login always redirect to this: http://testsite.com/wp-login.php?redirect_to=http%3A%2F%2Ftestsite.com%2Fwp-admin%2F&reauth=1 1, I add ...
0
votes
2answers
952 views

Hiding carousel indicators if there's only one post

I am working on a custom carousel (Wordpress + Bootstrap). The carousel is working without problems. However, I would like to hide Bootstrap carousel indicators and arrows if there is only one post. ...
3
votes
1answer
85 views

Exclude filter on front page

I am using this code in functions.php to append a button for link to a post. function new_excerpt_more($more) { global $post; return '<a class="excerpt-readmore" href="'. get_permalink($post-&...
0
votes
1answer
441 views

Second level subcategory

I'm trying to get anoter level subcategory to show in my select option. I've managed to get one... how can i get the other? <?php $taxonomies = array(CUSTOM_CAT_TYPE); $args = array('...
0
votes
2answers
3k views

Conditional two level dropdown filter for custom post type

I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a ...
0
votes
1answer
513 views

Display most viewed post from last 30 days is not working correctly

I've try several different loop to display the most viewed post from the last 30 days . . However its just showing the post from 30 dasy ago . . not from the last 30 days . . not the most viewed . . ...
2
votes
2answers
854 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
6
votes
2answers
22k views

How to get posts published between a date and today?

Is it a way to get posts published between a date and today with query_posts() ? Example : All posts published since 2012-04-01 Thanks EDIT : How to add the filter date on this Query Posts ? ...
0
votes
0answers
14 views

Pagination not working for custom post loop [duplicate]

I have a loop for my custom post, and it displays the pagination links fine, however when i click to the next page it displays the same posts again (event though the URL shows its on page 2). Below ...
3
votes
2answers
3k views

get_template_part from plugin

This is default get_template_part function inside WordPress: function get_template_part( $slug, $name = null ) { do_action( "get_template_part_{$slug}", $slug, $name ); $templates = array(); ...
0
votes
1answer
37 views

How to remove the most recent post from $the_query

Apologies for a very basic question: I've been searching for hours and can't find a solution. I have a Wordpress page that displays all posts of a particular custom type by using WP_Query to return ...
0
votes
1answer
13 views

Exclude page from loop results

I am having difficulties excluding a specific page from my main index loop in my child theme. I have the following function found in functions.php that modifies my index.php loop so that it displays ...
0
votes
0answers
24 views

Timeout error 504 with 2 query_posts , how can I make them work?

Im experiencing a error: ERROR 504 - GATEWAY TIMEOUT then ERROR 500... Database connection problem. etc. I have this loops that works fine IF in logged... if not, it doesn't work... Update: I ...
0
votes
0answers
5 views

Expire posts with Pre and Posts Get new WP_Query in Categories

On my website I use Get Pre Post to display active posts (without an expiration date and those who are yet to expire), and also new WP_Query use to display only posts expired in each category page. ...
0
votes
0answers
15 views

Trying to get property of non-object in: $tag->slug

I suppose this is a very common propblem but. This function I was using was in fact not a problem until a couple days ago , that the debug starts showing this message: PHP Notice: Trying to get ...
0
votes
1answer
661 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => '...
0
votes
2answers
1k views

Including all post id's of a custom post type into an array

For my single.php (products.php), I try to build a navigation via which the user can switch between products based on the meta key "price". I want to put all id's of the products post type into an ...