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
1answer
93 views

How to check if meta box value is false for all posts then do something based on that

I have the following code in template-home page which queries for a custom post type, called reviews. I have a Meta Box for the Custom Post Type where I can write the Author, Article Link, an excerpt ...
-1
votes
1answer
95 views

Display custom post type posts first, then default posts

A normal author.php template has a single loop that displays a list of all the author's posts. I'd like another loop place just above this normal post loop that lists all author's (defined) CPT ...
0
votes
1answer
32 views

how to place Post and page content side by side

Dear Stack Exchange Wordpress community, I am interested in having two loops on the same page, having the larger one display the Page content and a sidebar display blog posts,and do not know how to ...
1
vote
1answer
267 views

Create a random unique 6 digit number as custom field for custom post type

I use the following function to create a random unique 6 digit number and save it in a custom post type meta field. I am unsure about the use of rewind_posts() inside a while loop. The idea is that ...
1
vote
1answer
103 views

Get Pagination (WP-PageNavi) not to work

I have several problems to get the pagination work. I have a custom page template, in there i need to display all blog posts. I build up the following "query" and build up my html structure: $paged ...
0
votes
1answer
119 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. ...
0
votes
1answer
152 views

Ordering posts by custom field and grouped by month

I need display all custom posts (event), order them by custom field (date) and group by month: September Event 1 Event 2 August Event 3 July Event 4 Event 5 I know, it is frequently asked ...
0
votes
0answers
20 views

WP home page loops

I found a post regarding loops on home page. Pagination returns 404 after page 20 I have several post categories. On the home page I want to loop through two of them in two different loops and ...
0
votes
1answer
102 views

Query *only* sticky posts

I've been using the following query to try to output only posts that are marked as stickies: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 2, ...
0
votes
4answers
53 views

custom loop issue

I am trying to get a custom loop to work and I can not see why it is failing. $args = array( 'category_name' => 'audio', 'posts_per_page' => 6 ); $sound = new WP_Query( $args ); ...
0
votes
0answers
34 views

Custom fields in a loop won't display without post_id

I am trying to loop through the posts to extract custom field values to use it in html. Using Advanced Custom Fields and the plugin has a nice get_field() and the_field() functions that should work in ...
6
votes
2answers
88 views

A search for '0' returns results

I have a a CPT set up with a custom taxonomy attached to it. I recently noticed that if I search for 0 (zero), in the back-end as well as the front-end, it gives me results. None of these resultant ...
0
votes
0answers
76 views

Show posts by tags excluding current post

I'm having some trouble trying to display current posts by tags and not adding the current posts. Here is my work in progress and I'm using a custom post type. I'm not exactly sure on what to add in ...
0
votes
1answer
18 views

Add specific class to featured posts

Actually I'm using this loop to get my posts in homepage: <ul class="news"> <?php // The query $page = (get_query_var('paged')) ? ...
1
vote
1answer
60 views

create a page which displays a list of categories title+ short description?

I have a code that loops through all categories and: 1.organize them on a Hierarchy of (parent) category and its child categories 2.echo the titles +short description of each category +add "read ...
0
votes
1answer
30 views

how to use pre_gets_posts to exclude one queried ID from homepage loop

I want to exclude the last post of the category "prima pagina" from the loop of my home page because I've got a dedicated box for it and I don't want duplicates on the page. I'm using a child-theme ...
0
votes
1answer
39 views

Using two differents loops on a page with custom post and no duplicate content

I'm trying to figure out how I can display the content of a query post within a page. Basically I'm using contact form 7 specials tags but the problem is that it will only work if it is inside a loop ...
0
votes
1answer
16 views

Adding options to loop

I made my first theme for Wordpress, but I am interested in one thing so if anyone can point me to right direction. My theme has 4-5 loops, depending on category that it need to show. I want to add ...
0
votes
1answer
76 views

Make custom Wordpress comments list

i'm making a custom Wordpress template and I've made this HTML code for single comment template: <div class="comment" id="1"> <div class="useravatar" ...
0
votes
2answers
267 views

how to upload image using wp_handle_upload

hi i am new on WordPress can somebody tell me how can i upload multiple images using wp_handle_upload in a loop for($i=1;$i<count($_FILES['myfile']['name']);$i++){ ...
0
votes
1answer
26 views

Optimizing the blog loop

I've got such post loop: <?php global $post; $post = $post_object; setup_postdata( $post ); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'post_type' ...
0
votes
1answer
37 views

Is there any good reason for two CSS files to @import each other?

I'm working on some critical style revisions for a client's WordPress site that was designed by another team. The CSS seems to be a tangled mess. One of the idiosyncrasies I've found is that the ...
0
votes
0answers
67 views

Multiple loops on search results page return empty on no results

I've got a search results page that has several loops on it. One loop returns our most popular posts, and the other returns the top 5 of another custom post type. We use these loops on the blog, on ...
1
vote
1answer
84 views

Post loop for all taxonomy terms

I currently have a custom taxonomy set up called development-category at the moment, if I want to set up a posts loop for each of these taxonomies, I'm having to do it as follows: <?php ...
0
votes
1answer
63 views

Limit tags shown in post

How do I limit the number of tags shown using the code below, without having to add $count=0; or if ($count <= to the query, but only for the home page, and a different number for each set of ...
3
votes
1answer
109 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 = ...
0
votes
0answers
14 views

Grouping posts by Custom Taxonomies and wording by date

I have already figured out how to create a loop that pulls posts from a Custom Posts Type that I created and grouping them by terms of a Custom Taxonomies. Sorting of terms Alphabetically works ...
0
votes
1answer
65 views

Where to find the code used to render a page that has a shortcode and a template defined?

I'm new to WP and trying to configure the 'My Account' page on a WP site. The site uses the Paid Memberships Pro (PMP) plugin. In the WP admin console > Pages, there is a page called 'My Account'. ...
0
votes
2answers
50 views

Where should I use post_class()?

I am trying to learn WP Theme development. And as I have understod it is important to use "post_class()" since plugins may need to use it. But what I not understand is where I should use it? Should ...
0
votes
0answers
29 views

How to get the categories from Related Posts using “Posts to Posts” plugin

Sorry if this has been answered elsewhere — if it has, I have been unable find the answer — or if this seems like a basic question. But I am trying to use the Related Posts functionality built into ...
1
vote
1answer
219 views

Define Function in functions.php or plugin and call in theme loop

I need to define a function in functions.php or a plugin and be able to call it inside the theme's loop & outside. Example; I have a $product_price = get_post_meta(get_the_ID(), 'product-price', ...
0
votes
1answer
30 views

Post Format problem

I'v tried really a lot of solutions, and the one that works, it works half a way. Inside single.php I'v added <?php while ( have_posts() ) : the_post(); ?> <?php if( ...
0
votes
0answers
163 views

How to retrieve sticky post with Visual Composer's loop builder?

So I have a simple custom shortcode function build under Visual Composer with vc_map. <?php /** * Blog Posts * */ if( function_exists( 'vc_map_get_attributes' ) ) { $atts = ...
4
votes
3answers
251 views

Display Authors Comments on Profile Page

I am trying to display authors comments on their profile page (author.php), however both codes I tried seem to display everyone's comments. Also the second code is suppose to link to the specific ...
0
votes
0answers
250 views

Category filter with load more ajax

What I am trying to do is to do an Ajax request to filter posts on category click depending on the category id, then apply load more posts by ajax. Problem: when I fire the ajax call by clicking on ...
0
votes
0answers
37 views

When can a template skip the loop?

I've reached another point with WordPress where something simple is stumping me. In working with an older theme, I have some page templates that do not call the loop. They simply use ...
1
vote
1answer
241 views

Only display videos and images in the_content() within loop

The issue I am trying to solve is within the WordPress loop, I only want video embeds or images to display, not any text. Currently, when creating a new post (Standard format) in the WordPress ...
0
votes
1answer
70 views

How to call custom single post?

newbie here playing with php stuff, wanna learn. So the problem is. I have created custom posts and data from those is shown in a widget. Now i want to create custom single posts for those custom ...
0
votes
1answer
79 views

Get meta value when the page is a blog archive

I'm using custom metaboxes on my pages. For example: header icon. I created a page for the news on my site. I selected it as a blog archive page under Settings->Reading page. Unfortunately I can't ...
0
votes
0answers
34 views

How do I prevent an infinite-loop. wp_insert_posts + JSON

I'm downloading posts from JSON file with this code: $bands = json_decode(file_get_contents('json file url'),true); $arrayLength = count($bands); for ($i=1; $i <= $arrayLength-1; $i++) { ...
0
votes
0answers
9 views

I want to show a list of all the custom taxonomies, and under each a list of some posts that match that

Does anyone know how they might do that? I imagine it would involve getting the list taxonomies, and then iterating through them with php to, and for each taxonomy item, querying the posts and ...
0
votes
0answers
28 views

Category page that displays 3 posts from each subcategory

Alright, so my main menu I am adding category "MainCat" that has subcategories i.e "SubCatOne" "SubCatTwo" etc.. When I click on that page I see all posts from all categories on it, unorganised (below ...
0
votes
1answer
21 views

WP_Query secondary query failing

I'm needing a couple queries on front-page.php and am at a loss why this is not working. My first query works fine, however, my second one specifying the category (or even nothing at all) never ...
0
votes
0answers
29 views

Loop using selection field to display content ACF

I 'm trying to create a loop to show only the contents of a multiple choice selection I have in the ACF ! I tried to do the consultation via WP_QUERY as explained in the ACF site , more does not work! ...
0
votes
1answer
132 views

Exclude first post (sticky or not) from the loop using query_posts()

I'm using query_posts( 'offset=1' ); to exclude the first post from the loop. However, if the first post is a sticky post it will be shown and the second (non-sticky) post will not be shown. Is there ...
0
votes
1answer
38 views

numberposts not responding to wp_reset_postdata()

I am working on a loop where I want the content (from 2 separate categories) to be displayed like this: 1 large format post, 1 random product, 2 small format posts, 1 feature post ...repeat. In order ...
0
votes
1answer
37 views

Returning One custom taxonomy term name

I have a custom taxonomy called cities and right now the only city is las vegas. I am trying to use the code in question to echo "Las Vegas" - for the posts that are associated - on the search results ...
0
votes
0answers
83 views

Problem with pagination in custom loop on front page - no back link

I have certain problem: I have several queries on main page. When I call new WP_query on front Page (custom loop in main loop), make custom pagination, but it doest work in case if I want "Previous / ...
0
votes
1answer
44 views

Tricky Custom post loop

I'm building a site using "theretailer" as a base and I cant figure out where to place code to get the loop to work for a custom post type "News"? the loop the theme uses is ...
1
vote
2answers
105 views

Should I use loop in the single.php file?

I read many tutorials, and checked many premium/free theme's source and most of them use loop in the single.php file. The single.php file only displays one post, so I think the_post() is enough, ...