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
2answers
105 views

How to tell if all posts are only in one category?

I have a category.php page which redirects users to a certain template page if the article in the output is in a category. However, I am seeing that if I have say 10 articles,and only one is in the ...
0
votes
1answer
484 views

Problem with WP_Query loop and search term

I have a custom query to display random posts in my sidebar like this: $newQuery = array( 'post__in' => get_option('sticky_posts'), 'post_type' => 'ad_listing', 'posts_per_page' ...
0
votes
1answer
138 views

List categories of a post hierarchically?

Let's say I got the following categories: Style | + Shoes + Pants If I make a post and put it in the Style and Shoes category, it will list them alphabetically instead of hierarchically. So ...
0
votes
1answer
2k views

Skip 5 latest post while paging?

In the index.php page, I need to skip 5 posts (the last 5 posts in the blog). I use the WP-Paginate plugin, but all pages show the same. I'm using offset=5, this is my code: <?php $paged = (...
0
votes
1answer
390 views

Error while excluding a post from another loop (using its ID)

I'm trying to get the ID of a post in the first loop (using <?php $postid = get_the_ID(); ?> ) and use it in a variable ($postid) to exclude that very post from a second loop (using ...
0
votes
1answer
618 views

“Order” doesn't work in custom loop?

I have a custom loop (used in a shortcode) that lists items from custom post type. Everything works fine but "order" for posts doesn't work, no matter what I type as order attribute on post page - ...
0
votes
1answer
392 views

get post images to link to external sources

I'm buiding a site that lists the most recent posts on the front page, the site is a recompilation of interesting articles and images so it doesn't make sense to link to the individual post. I ...
0
votes
1answer
689 views

Last post in loop - custom post types

I added the below code to my index.php and it's working fine. Then I added it to my type-[post_type].php file and it's still displaying the code for the last post on the page. I can't figure out why. ...
0
votes
1answer
2k views

How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?

This is the topic loop of the bbPress plugin. How can I make it stop when it reaches two posts? (Topics custom post types)? <?php /** * Topics Loop * * @package bbPress * @subpackage Theme */...
0
votes
1answer
3k views

WordPress: query pages except remove one page

I'm currently running this query to get pages (not posts) from the site section: query_posts("post_type=page&post_parent=6"); I'd like to remove one page, 271, from this query. Based on this ...
0
votes
2answers
713 views

Show a Category X's custom post type on Category X archive page?

I created a custom post type "landing_page" to hold content I want to display on the top of category archive pages. So for each category, I have one landing_page entry tagged with that category. What ...
0
votes
2answers
810 views

Filter or order based on custom field

I have added a custom field to some posts called 'frontpagerank' The plan is to order the posts by this value but first I just want to filter out any that don't use a front page rank. I have achieved ...
0
votes
1answer
864 views

get_post_meta printing empty fields, but it shouldn't be

I'm trying to call some hidden custom fields into a meta box. The custom fields are the same - a maximum of five named _link and five named _url, with sequential numbers following (eg _link3). However,...
0
votes
1answer
849 views

Exclude parent categories from the_category() within the loop

I have typical parent and child categories setup as follows: Food potatoes corn beats Sports soccer football hockey etc. In my index.php template I'd like to list the categories of the ...
0
votes
1answer
961 views

Exclude posts without category from loop

I'm trying to exclude all the posts that doesn't have a category assigned to from the main loop, i searched everywhere and i found a billion ways to exclude some categories or filter from specific ...
0
votes
2answers
1k views

Modify main loop query for paged and meta key

I try to change the main loop in such a way: I have a meta key for displaying featured items, that should be shown only on the home page of the a blog. I pull them in a code separate from the main ...
0
votes
1answer
674 views

Display different number of posts from one category on the different pages

according with Pagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used: ...
0
votes
2answers
2k views

How can I change how my tag pages display?

Ok, I'm using the TagCloudShortCode plugin. I have a problem with how my tag pages display.... I want them to display the way they show on my main page, with the image and more button... how do I ...
0
votes
1answer
221 views

Is there a way to define the $post var outside the loop?

I am trying to speed up a wordpress site by condensing three wp_queries into one. I have a need to seperate categories, so I am making the call and defining 3 arrays to hold the post using a switch, ...
0
votes
1answer
381 views

Create a Loop with Posts Ordered by Most Recent Comments

Using query_posts, how can I order the list of posts so the ones with the most recent comments are at the top? I'm looking for something similar to how Questions here on SE are ordered when you ...
0
votes
1answer
22 views

Submit button inside foreach loop updates all table rows instead of one row [on hold]

I created this simple function to update a row inside a table called wp_todos function update_completed_todos($id,$complete) { global $wpdb; $table_name = $wpdb->prefix . 'todos'; $...
0
votes
0answers
19 views

wordpress wrap every 3 posts in a div after the very first post in a loop so that the fist loop is a featured post [duplicate]

I want to add every 3 posts in my index.php file in a row div but I would like to exclude the first post so that I can style the first post differently. I currently have the loop working for every 3 ...
0
votes
1answer
11 views

QueryObject un-orders post

Hi I'm using this code below to display post from a specific category and also to style the first post different from the next 5 post. <?php $queryObject = new Wp_Query( array( 'showposts' => ...
0
votes
0answers
20 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
18 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 ...
0
votes
1answer
26 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
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
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
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
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 ...
0
votes
1answer
38 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 ...
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
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 ...
0
votes
0answers
7 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
0answers
25 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
33 views

Redirect loop in WP Admin with SSL

we're running a membership site on the latest Wordpress 4.5.3 hosted on Bluehost. We need to move the website to SSL so made some changes in .htaccess, wp-config.php and added Wordpress HTTPS plugin ...
0
votes
0answers
21 views

Prevent the Loop from running on tags page

I wrote a custom post query for the tags page (tags.php), which queries all posts. I therefore do not need the Loop on that page, because it only queries those posts related to the tag. Is there any ...
0
votes
2answers
47 views

display post multiple times based on array of dates

I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times . In my ...
0
votes
0answers
81 views

jquery Load All Wordpress Post and Pages Into Div Using AJAX

Ok So I am working on my first Wordpress them based off html5 template that I created myself. Right Now On the site I have a continous music player. It allows the users to listen to music while ...
0
votes
0answers
13 views

Filtering search results for nested loops

So I have a list of companies that have counties and cities. I need to be able to do something like /findmanagers/miami-dade/ and then build a query that fetches all the companies we have listed ...
0
votes
0answers
32 views

Custom Page Load by wp_query

Is there a way I can use wp_query to retrieve custom pages and posts, and display them on the front page of my WordPress site? I'd like to do that for every custom page I have, to end up with a one-...
0
votes
1answer
33 views

Dividing the loop to style post differently

I'm using a plugin that displays post and shows them in a certain area on my site, such as the sidebar or anywhere i put the <?php;?> code, but only if the author that is writing the post clicks ...
0
votes
0answers
27 views

Using custom query on a custom page for a custom post type

I have setup a custom page (page-mypage.php) and I want to list all posts of a custom post type when I use the loop in my custom page. I'm using pre_get_posts hook to modify the query. Problem: In ...
0
votes
1answer
41 views

How to keep a CPT stick to specific position?

I have created a CPT (esp-publicitarios) using Metabox plugin with the following code: add_filter('rwmb_meta_boxes', 'elclarin_register_meta_boxes'); function elclarin_register_meta_boxes($...
0
votes
2answers
46 views

Get Sticky User in user loop based on user role

I have this shortcode to display a loop of user avatars with order by registration date. function Profiles() { $args = array( 'orderby' => 'registered', 'order' => 'DESC', '...
0
votes
1answer
61 views

Group posts that matches a term in a loop

I'm working on a website that shows a lot of products, and this is my structure: Product (custom post type) -->Brand (custom taxonomy) ------>Brand A (custom term) ------>Brand B (custom term) -->...