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
0answers
42 views

WooCommerce: Making a loop create divs of categories, with category products inside

I have a php/wp script written which in theory should print a div with a category name, description, and all of its products inside. The code looks like this: <?php $args2 = array( 'taxonomy' =&...
0
votes
1answer
88 views

How to change post count in wordpress loop?

Hey I am attempting to customize my WordPress post loop to create different post styles for a certain set of posts. For example the first three posts would be styled in it’s own way, the next four ...
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
0answers
23 views

Duplicate Custom Posts

I am having trouble with a site duplicating posts. It will duplicate "page 2" on "page 3" and it will duplicate one other specific post. It also isn't showing all the posts, but I think this has to do ...
0
votes
0answers
18 views

WordPress loop by three meta values with random order

We have three custom fields with names plan_name1,plan_name2 and plan_name3. Need to check if these meta keys has values (1,2,3) OR (2,3,1) OR (1,3,2) OR (2,1,3) OR (3,2,1) OR (3,1,2) We mean ...
0
votes
0answers
24 views

Terms showing empty inside a loop

I have the following problem: I have 2 taxonomies that belongs to a custom post type What i want to do: Loop = taxonomy 1 loop = taxonomy 2 loop = post type My code works but, it shows ...
1
vote
0answers
55 views

Display Featured Image On Hover in Seperate Div [closed]

Hi I'm trying to accomplish showing my featured thumbnail on hover. Here is a photo example. The photo on the left is the featured image for the first post on the right. I want first post ...
0
votes
2answers
408 views

Trying to list out child pages with WP_Query

I'm trying to list out all the child pages of a custom page I've made. In my custom page, I'm doing this to list out the pages: <?php get_header(); ?> <?php $subpages = new WP_Query( ...
0
votes
1answer
1k views

WP_Query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
0
votes
2answers
3k views

How to exclude specific category from the get_the_category(); array

In my loop I've added: <?php $categories = get_the_category(); $separator = ' '; $output = ''; if($categories){ foreach($categories as $category) { $output .= '<span class="post-...
1
vote
1answer
54 views

Make a custom loop inside single.php with pagination

I want to create a custom loop inside a single-ediciones.php file and I need pagination (actually AJAX pagination). I need my normal loop because I need to show some data of the CPT "Ediciones" and I ...
0
votes
1answer
16 views

Getting the Most Recent Posts from Multiple Categories

I've got a page (page, not post) that near the bottom of the page I want to get the most recent 15 posts from a set of categories. I'm new to doing this and thought I was doing it correctly. The div (....
0
votes
2answers
116 views

How to overwrite orderby with add_query_var

So I would like to have an archive that displays its posts in a random order. <?php $query = new WP_Query($query_string."&orderby=rand"); ?> But also then if the user chooses they ...
0
votes
1answer
31 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 ...
1
vote
3answers
120 views

get_the_content not working in loop?

I am trying to modify my loop to save post data by category. I found some code on this site that saved the post's titles based on their categories and tried to modify this to save the post's content. ...
1
vote
2answers
57 views

if ( is_home() && ! is_front_page() )

I see the following code a lot in index.php files. I understand that is_front_page() returns true when viewing the Site Front Page (whether displaying the blog posts index or a static page), while ...
1
vote
1answer
838 views

Pagination Issues using WP_Paginate Plugin

So I have read more posts and articles about this issue than I care to admit and still nothing I can find works. Here is the issue - I can not get the pagination to advance and it shows all the same ...
14
votes
9answers
31k views

Get post content from outside the loop

Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page.
0
votes
0answers
50 views

wp_get_archives doesn't work with 'post_type' with WordPress 4.5

wp_get_archives support the post_type parameter from 4.4.0, so I decided to add a <select> on the cpt's archive page. Unfortunately wp_get_archives returns with NULL. Do you have any idea what'...
0
votes
0answers
47 views

Display category name only once inside loop

I have been researching on how I can output the category name on a wordpress loop for custom post only to display only once. If there are any posts under the same category, the category name will not ...
0
votes
1answer
44 views

Wp_query with 2 meta keys and array of meta values

Hi in my post_type=shop i have 2 meta keys and array of values Custom fields Name Values cu_status pending,processing,completed cu_date 12-Jan-2016 , 13-Jan-2016, ...... any ...
0
votes
0answers
39 views

Omitting the latest entry with custom type and taxonomy term from the loop

My agency has inherited a client with a customized theme provided to them from a separate agency, which farmed the work to another agency off-shore. The documentation for this theme is non-existent ...
0
votes
0answers
18 views

List posts that are geotagged within a certain area

I'd like to geotag some post on WP with latitude and longitude in a custom field. It's very easy to show a map with this data but what if I want to show all the posts that are geotagged, let say, in a ...
0
votes
1answer
48 views

How to make a wordpress loop file that displays posts based on certain conditions

Am recently trying to learn the framework aspect of WordPress,so i want to build a user homepage that only displays posts from other registered users, but the posts that will be displayed will have to ...
1
vote
1answer
93 views

Custom Post Type Pagination Not Working On Archive Page

I've spent the last 3 hours trying to get pagination to show up on my custom post type archive page. I sort of understand that pagination only works with a default loop and once you modify the loop, ...
0
votes
1answer
63 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
2answers
36 views

How to Order By Two Custom Fields?

Note : This is not a duplicate question to If value present, order posts by two consecutive custom fields. After filtering a custom filed, I need to order by another custom filed. (The above link ...
1
vote
1answer
73 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....
-2
votes
2answers
45 views

How to create a loop where loop changes every post?

How can I create a type of loop in WordPress where an image moves left or right for each post? I.e. first post image will be left, second post image will go right, third post image will go left, and ...
3
votes
6answers
4k views

Get date of last update outside of loop

I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using get_the_time() but there doesn't seem to be a "loopless" ...
0
votes
1answer
41 views

Adding a html class based on post count

I'm creating a grid of columns and need to add a css class to each column at the end of the loop based on the amount of posts returned so it returns something like this: <div class="column-3"</...
0
votes
1answer
955 views

Search.php - return number of results but cannot loop through

I have a following search.php page (this is just the code required for problem presentation). Why is my $total_results returning a number of posts found, but when I do a loop though it always print ...
0
votes
2answers
69 views

How to display post list in a table layout (multiple queries in single loop)

I am setting up an events page for my website. This page is using a loop to display a list of acts performing at different venues month-by-month. When a viewer comes to the page, they use a simple ...
0
votes
1answer
955 views

group search results by post type?

My site has 3 unique post types: Default Blog posts ("post") custom type "lesson" custom type "series" When the user searches the site, I would like pertinent results from all 3 post types to show ...
0
votes
0answers
17 views

Loop through author and edit post tags

I'm setting up a 'free marketplace' for a friend based on wordpress and a woocommerce theme (makery). Each user has his own shop and products. Both the shop and products are custom posts that belong ...
0
votes
1answer
20 views

How can I make this iterative conditional within the Loop work via function?

I want an element to appear within the Loop, but only at certain points. I can supply the condition - in the form of a "flag" that gets set when the condition is fulfilled, preventing further ...
-1
votes
3answers
486 views

How can I implement pagination on custom category page?

I have created a custom template page for every one of my categories. I am using a foreach loop in order to fetch the posts of this specific category in my page. if (is_page()) { $cat=get_cat_ID($...
2
votes
1answer
3k views

Display products for a category, sorted by post_excerpt

I'd like to display a list of products for a certain category, sorted by the post_excerpt. The original code I used was this: $args = array( 'tax_query' => array( array( '...
1
vote
0answers
28 views

Infinite Scroll and DFP

Well , I'm trying the next loop to make work DFP in an Infinite Scroll. I thought that if I change the name of the Slot I could get the banner shown, so I tried this: <!-- DFP Controller --> ...
0
votes
1answer
26 views

Posts Per Page is Not Returning Correct Number

I have a single.php with 3 loops one the page (related posts, latest posts and the actual content). All loops are using the wp_reset_postdata(); at the end. For some reason my post_per_page ...
-1
votes
1answer
18 views

How to separate posts loop in to two columns? [duplicate]

I need to separate WordPress posts loop in to 2 columns , left ( all odds ) and right ( all evens ) . Currently I am doing this with 2 separate loops but would like to make it with one and would ...
0
votes
2answers
82 views

Pagination Not working on Home Page with 2 Query

I have two loops in home page (index.php) <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 3, ); $another_query = new WP_Query($args); if( $...
3
votes
1answer
2k views

Have different number of posts on first page

I need to have a different amount of posts per page on the first page that on the other pages. For example, this is what I need Total posts: 6 First page: showing 3 posts Following page: showing 2 ...
0
votes
1answer
23 views

Exclude current custom post on single post

I'm trying to exclude the current custom post that is viewed from a list. I've tried with exclude but it still displays it. Here is the code I have on single-works.php: <?php $currentID = ...
0
votes
0answers
30 views

why does “else” break “if” statement?

I dont understand why this is happening. The winning code is a hash of the post ID. A link is sent to email with the winning code and a link to verify that youre the winner. Now here is where ...
-1
votes
2answers
73 views

How to create a loop that will display one post and stop?

I am trying to create a part on my wordpress theme that will only display one featured post. I have installed this plugin - https://wordpress.org/plugins/featured-post/ . I know I am supposed to ...
1
vote
0answers
73 views

Trying to use AngularJS with WordPress without any API

I understand one can do this using the JSON RESTful API from WP but I don't want to go that route since it only works with sites on Wordpress.com and not on localhost (at least that's what I was told ...
0
votes
1answer
93 views

2 Loops on one page - pagination of 2nd loop ignore array of excluded posts

I have 2 loop on one page. First one shows 11 recent posts in rand order and pushes each post ID into do_not_duplicatearray. $argsRandom = array( 'numberposts' => 11, 'fields' => 'ids' ...
0
votes
2answers
63 views

Display specific page (that is child) content on parent page

I have problem displaying child page content on parent page (both static). I can display other page content but only if on same level. It dosent work in relation parent - child. <?php $...
1
vote
2answers
819 views

Most recent post from another database

I am trying to add the most recent post from another Wordpress database (on the same server in all actuality), but am getting the following error: Fatal error: Call to undefined method wpdb::...