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)

1
vote
1answer
120 views

How do I get the category URL from get_the_category?

My loop below shows the latest 4 posts from the same category as the post currently being viewed. Its located within single.php. I'm trying to get the URL of that same category so I can link back to ...
0
votes
0answers
14 views

why is the value of one field different from another if they are filled with the same variable?

A form is submitted containing a users email address. When the form is submitted, the page that processes the form creates a new post, and it sets the value of the custom meta field called 'entryCode' ...
0
votes
1answer
100 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
1answer
54 views

Show Posts By Custom Field

I’d like to add 2 custom fields to my posts: show_post_on_home_page home_page_posts_order_sequence I then want my home page to show only the posts where show_on_home_page == true, ordered by ...
0
votes
1answer
34 views

Different Loop for tag pages?

I have a theme that uses one template file to render the index of the blog, the loop is basic: if ( have_posts() ) : while ( have_posts() ) : the_post(); I want to use another custom loop for all ...
0
votes
0answers
15 views

The Loop doesn't work when using RewriteRule

I am using .htaccess RewriteRule on my page. When user goes to /news RewriteRule actually loads /?nav=news On that page, I use The Wordpress Loop to show recent posts if (have_posts()) { ...
0
votes
1answer
64 views

How to check if “is single” page

I know – at first glance the problem may seem easy to solve – and I hope it is – I just can't figure out where/ how to check if I'm really on a single page, or just rendering a single page in the loop....
0
votes
0answers
46 views

Loop through custom post type taxonomies

I have created custom post type products and I want to show categories on products archive. I have this code <div class="container"> <div class="boxes"> <?php $cat_args = array( '...
3
votes
1answer
94 views

WP_Query: Why is sticky post not first item in loop?

I've got a custom WP_Query loop based of meta_value variables: $meta_cat = get_sub_field('category'); $posts = new WP_Query( array( 'cat' => $meta_cat, 'posts_per_page' => get_sub_field(...
4
votes
2answers
65 views

Unit testing to simulate the loop

How do you construct unit tests with PHPUnit and the WordPress test framework that simulate being in the loop? For instance, if I want to test a function that is only able to be called in the loop ...
0
votes
1answer
39 views

Create a hierarchical loop at predefined markup requirements

I try to achive this in wordpress based on my theme: fullpage.js demo So I have a predefined markup for vertical sections (parents) and one for horizontal slides (children). Parents only contain ...
1
vote
4answers
104 views

2 loops on page - one with orderby rand second orderby date

What I'm trying to achive, is to set 2 loops on one page. First one takes 11 latest posts and sort them in rand order. Second show the rest of posts ordered by date. FIRST LOOP $args = array('...
0
votes
0answers
20 views

What is the best way to intercept posts/(topics) as soon as they are added by the user in a Forum in Wordpress?

I need to write a plug-ing for a Forum in Wordpress, that each time a user inserts a post/topic such plug-in is able to intercept the data in the post and then we make our analysis throught a function....
0
votes
0answers
30 views

Get first title post from an author

I want to display first title post from an author on my loop with this code: <?php $number = $count_post; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ...
1
vote
1answer
72 views

Custom Post Type within the Loop on Homepage (Page Template)

I'm trying to achieve something with the Loop and CPT. I've built a template page which will be the homepage of my website displaying articles and videos (the CPT). How can I add the CPT within a loop ...
0
votes
1answer
59 views

How to get the excerpt for is_home() outside of the loop isn't working

I'm wanting to get my excerpts outside the loop and I learned how for everything but the blog page. After researching this topic I was able to produce two Q&As: Get excerpt using ...
-1
votes
1answer
28 views

Display Page featured Image as well as Posts featured Image

Ok, I have hit a bit of a roadblock. I have a page that has been set to display the posts (which have their own featured images). I tried calling the posts featured image in the loop (which worked), ...
0
votes
1answer
36 views

Exclude post on loop by multiple meta key value

I need to exclude the loop two post with different values in your meta key (the same). I investigating got this code that works fine if I enter only one value in value =>. But if I want to enter ...
0
votes
0answers
28 views

Developing Wordpress Plugins with storing and exporting thousands / millions of data

I want to develop a plugin that will import and export WordPress users with csv file. But my concern is looping thousands or millions of data without exceeding php execution limit or Internal Server ...
0
votes
1answer
64 views

Display only text to WordPress loop without loosing the text formatting

I want to display text from content (only text) with the formating (paragraph, bold, italic.) on loop. When I am using this code: <?php echo mb_substr( strip_tags( get_the_excerpt() ),0,255); ?>...
0
votes
0answers
27 views

Set Popular Post by views weekly?

I've tried several times, but still didn't work. Anyone have an idea? EDIT: This actually works, but only get popular post all of time. I want popular post by week. what needs to be added? This my ...
1
vote
0answers
30 views

How to append element after thumbnail

Hey I just wanted to know how to add an element after the first thumbnail image in my loop. Basically I want an HTML div tag inserted after the first image in my post. Anyone know how to do that in ...
1
vote
0answers
14 views

Change the main loop Wordpress impact on the server?

I used pre_get_posts to change the loop of my Wordpress site. The idea of this loop is not show posts I define an expiration date, whose dates are added in a custom field ( postexpiry ) . These ...
0
votes
0answers
14 views

Pagination doesnt work for first 19 pages

I have this straightforward pagination form that used to work just perfect: function theme_pagination() { global $wp_query, $wp_rewrite; $wp_query -> query_vars['paged'] > 1 ? ...
-1
votes
1answer
46 views

Show linked products using wp query and woocommerce

Cannot find any information anywhere about pulling the linked products? I need to create a custom query to load the linked products but could only find related. Any information?
1
vote
1answer
115 views

Two custom loops, pagination, offset

I have two Loops using WP_Query. The first loop shows X posts. No pagination. (loop A) The second loop shows Y posts. With custom pagination. (loop B) It kinda works; but you can see the second ...
1
vote
0answers
39 views

Posts active and expired in different loops

I am in search of the best way to display pages active posts categories and expired after a certain period. I want to display active posts or have no expiration date in the main loop and those that ...
1
vote
2answers
36 views

Checking if post exist, then doing things

Trying to do: Trying to create a new post on the first entry to a contest, then updating that existing entry upon subsequent entries, so I can have one post per entry, but allow multiple entries. ...
0
votes
1answer
18 views

How to stop the continuation of posts on the second loop from where the first ended

I recently built a theme that has slider on the index page that loops through posts to create the content of the slider(used increment to stop at five posts only), but for some reason that is just ...
0
votes
1answer
57 views

Inserting CPT and static content at every X post, is this possible?

I'm working through a spec list for a new project which has the following feature: Display all CPT's from a specific category on an archive page, then insert an advert (CPT) into the loop after every ...
1
vote
1answer
54 views

Two near-identical custom field types - one works, the other doesn't . What can cause this?

I'm using Advanced Custom Fields to add meta information to a custom post type and in ACF I've created two different 'Select'-dropdowns - one is called 'series' the other 'classification'. I run a ...
4
votes
1answer
44 views

Apply styling only to first page sticky posts

I'm using the following bit of code to highlight sticky posts: <?php if (is_sticky()) : ?> <div class="col-md-12 box-01"> <div class="content"> <?php endif; ?> The ...
0
votes
1answer
72 views

Alternative layout the loop

i'm trying to make an alternative loop as found here on stackexchange, it has been a great help to what i've achieved so far, but i'm stuck now. The goal is to make the newspage look like this The ...
1
vote
1answer
108 views

Integrating Orbit slider into wordpress through custom post type

I am currently working with FoundationPress, It is a great starter theme loaded with cool features. I would like to create a custom post type called "slides" which will be displayed on the homepage ...
2
votes
1answer
71 views

How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()

I'm using the code from miguelpeixe's 'WordPress Query Multisite' in order to create a custom loop for my WP Multi-site's 'child sites.' Within this loop, I want to nest another loop that will pull ...
0
votes
2answers
52 views

the_content() stop images being pulled through

I have created a custom post type to pull through the date, title, thumbnail and content, some of the posts have images and the_content() is pulling through those images and I don't know how to stop ...
1
vote
1answer
119 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
2answers
61 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 ...
1
vote
0answers
128 views

How to use jPList with search results

I've been working on a real estate site and looking for a way to refine search results page + update pagination, instantly, like the big name sites (ie hotpads.com, trulia.com, hotels.com, etc.). ...
0
votes
1answer
134 views

Loop through Navbar, Output Icons

I'm trying to loop through my Navbar in WordPress so that I can output some Icons at the end of the last link. I have this working but I end up outputting a Navbar and a list. I think this is because ...
1
vote
1answer
64 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
2answers
60 views

The loop seems stuck to a single (now deleted) post

At first I thought it was an ACF problem, but printing some values helped me to find out that somehow my Loop seems stuck on a single post, but only when some fields are concerned. To sum up my setup:...
2
votes
2answers
138 views

Sort Popular Posts by Views for the Last Week

I'm trying to sort the popular posts so it shows the most visited in the last week, but it hasn't worked. Anyone have an idea of why it isn't working? <?php $popularpost = new WP_Query( array ( ...
1
vote
1answer
40 views

Custom Shortcode, functions PHP WP_Query loop

I have the following code in my functions.php file:- function featured_properties_func( $atts ) { $args = array( 'posts_per_page'=> -1, 'post_type' => 'properties', ...
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';...
3
votes
1answer
125 views

Displaying post per day

Currently I have the code displayed below. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"> <a class="...
1
vote
1answer
86 views

Meta Key Value in current-user-only loop

I created a loop for logged-in-users-only which works perfectly for all data except for meta keys. I'd like to be able to also extract meta keys but had no luck so far. This is my loop (based on this ...
5
votes
2answers
198 views

How to list some posts first in the loop based on post id

I have a query for to display some posts . $args = array( 'post_type' =>'products' 'posts_per_page'=> 12, 'orderby' => 'meta_value_num', 'meta_key' => '_price', ...
1
vote
0answers
83 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 ...
-1
votes
1answer
66 views

Standard Loop - wp_query

I was readind this article (https://codex.wordpress.org/Class_Reference/WP_Query) and try run the Standard Loop, but I can't receive the any result. My code is this: <?php get_header(); /* ...