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)

3
votes
1answer
49 views

Displaying custom posts only if custom meta box's date is not expired

I have a problem with displaying custom posts - I want each post to show only if a date set in a custom field has not passed. I can't figure out the where I should put the if statement in the code. ...
3
votes
1answer
135 views

WordPress category & taxonomy loop with pagination

I have two taxonomies belonging to the same post type (posts). Adventure - belonging to the category taxonomy Adventure - belonging to the holiday-type taxonomy I want to run two queries: $args = ...
3
votes
1answer
145 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
2
votes
1answer
65 views

Double count view in archive.php

I'm having a hard time using this snippet I'm getting double views each time the post is queried. This is in my functions.php file: function getPostViews($postID){ $count_key = 'post_views_count';...
2
votes
1answer
306 views

Converting multiple loops into one single loop with pagination

I am using Isotope jquery plugin to filter/sort posts in Wordpress but to correctly filter the posts into the right order I have needed to output each category one after the other. To do this I've ...
2
votes
1answer
174 views

Replace default Wordpress search behavior with Sphinx

I want to implement Sphinx Search in my Wordpress site but I'm not exactly sure how to change Wordpress search behavior to use Sphinx. How do I get Sphinx Search engine to replace whatever Wordpress ...
1
vote
1answer
10 views

trouble calling an import class from an action in a plugin before wp_cron executes

I’m using the wp_crontrol plugin to call an action added in my functions.php file which then calls a function in my plugin file. WP gets to my function but can’t call the class, I get this error: PHP ...
1
vote
1answer
82 views

Wordpress have_posts() return false but count says “3”

The situation is this: I have created a custom post type which works perfectly, now I want to create a specific archive page template for the taxonomies of this post type. I duplicated the archive....
1
vote
1answer
120 views

angularjs not displaying all posts

I learned about angularjs today and I am trying to create a page for my search results so that I can be able to create facet filters. Currently I have a page template with the following code -- <?...
1
vote
1answer
65 views

Creating loop within functions.php

I'm using Woocommerce on my website, on the checkout page I've got a custom select checkout field with radio buttons. I'm using this working snippet within my functions.php: /** * Add the field to ...
1
vote
1answer
39 views

Checking array against author id in loop

So I have a function in Wordpress with a plugin that returns a list of friends as an array. The function code is here: function friends_get_list($tmp_uid, $friend_status=1) { global $wpdb; $...
1
vote
1answer
47 views

Posts per row on archive page (custom post type)

I have problem with showing posts in more than one row, if I have more than 3 posts. How can I set more rows if I have more posts? For example, if I have 7 posts, I should have 3 rows. Can I do that? ...
1
vote
1answer
46 views

custom-meta-box checkboxes from loop won't save

I tried to create a custom meta box with checkboxes, generated from a loop of a custom-post-type. I found this example here on WP Development, but I can not figure out why the boxes won't save. My ...
1
vote
1answer
134 views

pre_get_posts for two loops on same page

I'm using two loops on homepage, one is to show the 3 latest posts, and the other one to show the rest of the posts minus the 3 first posts. I'm using the following code for the pre_get_posts. ...
1
vote
1answer
150 views

Sanitize Custom Field Value in Meta Query

I'm using the pre_get_posts hook with meta_query args to filter an archive loop by dates. Basically, there is a custom post type of "events", and my users type in a date as a custom field for the ...
1
vote
1answer
106 views

How to return only one instance of each, from the entire loop

I´m adding a filter function in a taxonomy archive template. The intention is to add URLs for filtering in a sidebar, and i want it to return a set of ACFs like zipcode etc... (postnr in this example ...
1
vote
1answer
59 views

How to exclude the last post from a category(featured for example) from the main loop?

I am using 2 loops on the main page, one that shows the last post from the featured category and a general one with all the posts. The problem is that i get the last post in the featured category in ...
1
vote
1answer
81 views

Custom Post Types strange pagination problem

Have a strange problem with pagination, the query work fine when I'm in homepage, but if click for the next page I get a 404 error. Disabling permalinks settings, I saw that in the query string (when ...
1
vote
1answer
90 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
1
vote
1answer
240 views

Genesis multiple category custom loop 404s after first page

Ok so, I have a page which shows a feed of posts in the "news" category (url is: mydomain.com/category/news ), but the client wants it to also show posts in the "press-releases" category. So in the ...
1
vote
1answer
297 views

Custom Loop Using Shortcode in Custom Page Template

I am trying to output a custom loop created using shortcode in a custom page template. Here is the code I am using to generate the shortcode: function archive_sc( $atts ) { // Attributes ...
1
vote
1answer
40 views

How To Get Posts With A Specific Word

How to retrieve posts with a specific word in the loop. For example, I want to retrieve all posts with the title of the profile post (custom post type): http://www.wwefansnation.com/wrestler/dolph-...
1
vote
1answer
59 views

Echo all category names, apart from one

I've got this simple code, that creates breadcrumbs: function the_breadcrumb() { if (!is_home()) { echo '<a href="'; echo get_option('home'); echo '">'; echo ...
1
vote
1answer
380 views

wp_query inside the_loop

I am having this issue with my loops. I am making a shortcode that will be called from the main query. It will display on the front page from the_loop. for some reason that I can't figure out. The ...
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
vote
1answer
78 views

How to list posts with disabled/closed comments, with pagination?

i'm interested how to display all posts (from all categories) that have closed/disabled comments? I have tried using the comments_open() function inside the loop, that works, i don't know how to ...
1
vote
1answer
82 views

Access to Media Library

Im trying to find a way to pull random images from either a post or wordpress's built in image library. Im not sure how to query image uris from a post or the media library - is there a tag or method ...
0
votes
1answer
24 views

Two custom loops, pagination is MESSED UP!

here's my problem: I'm on single.php and am trying to display at the bottom of the post a group of four related posts first, and then a list of all posts using infinite loading. So I created two ...
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
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
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
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
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
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
1answer
62 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) -->...
0
votes
1answer
87 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 ...
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
1answer
43 views

Show one item per category of a custom post type

I'm having a custom type called portfolio with different categories. I want to display all my categories except one. I only want to show one item per category on my page. I'm been busting my butt on ...
0
votes
1answer
12 views

Highlight specific user with custom field value

I'm working on a Wordpress project with some friends from school. But there's a problem with highlighting a user on the website. The idea is to create a 'User of the month' thing. In the user ...
0
votes
1answer
25 views

Attachment Metadata inside of Loop

Basically, I'm trying to call attachment info to display withing a loop, for use in an image gallery. I know I need to use wp_prepare_attachment_for_js($attachment_id) but I can't seem to get anything ...
0
votes
1answer
49 views

Loop 1 user randomly

At the moment I am using wp_user_query to loop users from a specific role(leden) on a webpage. For the overview page this is working fine, but on my homepage I want to feature one random user. I was ...
0
votes
1answer
37 views

have_posts() return false on single post

I'm a little bit confused with the use of the Loop. This is my first theme and i just use index.php currently to display all my pages. It works fine for pages but have_posts return false when i try to ...
0
votes
1answer
74 views

meta_query not working properly

I'm trying to run a query that only displays items that meet a condition in an Advanced Custom Fields select box, but I'm getting nothing. Here's my query. Any help would be appreciated: <?php $...
0
votes
1answer
123 views

WooCommerce custom loop pagination on front page

I'm having custom page template that I use as front page of my theme. In that page i have section which lists woocommerce products using custom loop. I want to insert next posts pagination to that ...
0
votes
1answer
48 views

Infinite Loop after Genesis Theme Upgrade

I'm running WordPress on Microsoft Azure, and I've been having a lot of timeout errors any time I try to install or update plugins/themes. (I'm using a custom child theme, based on Genesis.) Today, I ...
0
votes
0answers
670 views

How do I paginate a get_posts() request inside another page loop (Paginating childpages)

The heading says a lot, so I'll repeat it here "How do I paginate a get_posts() request inside another page loop?" I'm using a page to display child-pages and I need to paginate them. Edit: Should I ...
-1
votes
0answers
32 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. ...
-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 ...
-1
votes
0answers
270 views

Buddypress registration page redirection loop errors after adding if(!is_user_logged_in)

I'm running WordPress Multisite install with BuddyPress (WP 3.9, BP 1.9). I'm using the code below to make the main website protected from not-logged-in users, and let them to visit only the ...