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
26 views

Can I use both a custom excerpt and a trimmed excerpt?

For each post, I use the custom excerpt field to write a custom excerpt (180 characters max) for each of my posts, which I use as the meta description of my post for SEO. When I show a list of my ...
3
votes
2answers
64 views

Ignore post by meta value in the main query

I use this function to insert at the beginning of the loop two post at my convenience (with meta key and value) add_filter( 'posts_results', 'insert_post_wpse_96347', 10, 2 ); function ...
0
votes
1answer
138 views

How to get the first image gallery of a product in woocommerce in a loop

I want to diplay a product with product image, and when visitor hover that image, will change to first image from product gallery I am using this code to display the image gallery, but displayed all ...
0
votes
0answers
14 views

Query a custom post type from a different WordPress install?

I have a client who would like to only create his items on one domain, but have a specific taxonomy of that custom post type display on a different domain (this is not multi-site...they are separate ...
0
votes
0answers
22 views

Use audio file like image featured

Attempt to get the url of an audio file in post content to display in the loop of the home page. I can only get it if the file is uploaded at the time of creating the post, but if I go to a post ...
1
vote
1answer
42 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
67 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
48 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
25 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
14 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
41 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 ...
0
votes
0answers
23 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
61 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' => ...
3
votes
1answer
38 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
28 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
101 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 = ...
0
votes
0answers
18 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 ...
0
votes
0answers
28 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
38 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
40 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 ...
0
votes
1answer
24 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
30 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
50 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
24 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
27 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
13 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
13 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
23 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
78 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
37 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
28 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
17 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
0answers
91 views

Wordpress slider with bootstrap carousel

I have create slider for front-page with bootstrap carousel, for slider content get from featured category, problem is the slider 1st, 2nd, 3rd displayed as list. normally layered with navigation ...
1
vote
1answer
50 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
52 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
37 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
50 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
58 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
45 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
49 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
62 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
0answers
20 views

Adding a custom product filter

I'm currently working with woo-commerce. I'm looking to add a custom product filter (I'm looking to build this as a learning exercise), currently my product categories pull back all products in that ...
1
vote
2answers
44 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
86 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
92 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
35 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
55 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 ...
2
votes
2answers
107 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 ( ...