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

Show different Google Map markers for different post_meta values

A lot of websites use it but suprisingly nobody tell us how to do it (right way). I have few ideas but Im not sure if this was the most efficient way - Im not very good with loops (under a year of ...
0
votes
2answers
109 views

divide custom field values in div every two values

i have this html mark-up to sort some data <div class="row"> <div class="col-xs-2"> <img src="images/member-schools/ms1.jpg" class="img-responsive"> </div> <div ...
-1
votes
1answer
29 views

Custom Post Type archive above Single Post in single.php (same author)

I don't know if this is possible but I'd like a separate cpt archive type of loop above the normal single post loop. Something like this in single.php archive-cpt (loop) single post (loop
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 ...
3
votes
3answers
8k views

get custom post type by tag

Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop. <aside class="supporting_images"> ...
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 ...
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
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
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
1answer
231 views

Echo a shortcode div after every 3 posts

In my wordpress home.php file, I have placed an increment loop with the help of a few stackexchange threads: <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while ...
0
votes
1answer
118 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
151 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
260 views

Sort posts by first letter in the title, not by first number

I have a custom post type that's used to display properties on a client website. I am sorting the posts by the title, but want to ignore any numbers included in that title. How would I sort posts by ...
2
votes
1answer
567 views

Can't show comments count per post outside loop

How can I show the amount of a comment per post outside the loop? I tried this in a function already: ' . get_comments_number . ' , but that outputted the text "array" on the screen... What do I have ...
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 ...
12
votes
1answer
251 views

Should we trust the post globals?

@toscho left a comment to this answer which had me thinking again. How much trust should we have in the global scope, specially regarding the post globals like $post? So what? The global variable ...
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 ...
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
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
266 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++){ ...
1
vote
0answers
124 views

Checkbox doesn't stay checked, conten

I'm using the morefields plugin to create textfields and checkboxes in the dashboard. For a test I have first created a checkbox on 'pages' if it was checked, the frontend showed the text ...
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
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 ...
0
votes
2answers
1k views

get parent content inside child posts

I have a custom post type where I've created 3 pages in a parent-child relationship. The pages are created like this : PARENT-CHILD-GRANDCHILD I want the child and the grandchild pages to get 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 ...
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 = ...
2
votes
2answers
861 views

Single Page Wordpress Theme - Using page templates

Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress "pages". How I have initially setup ...
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
64 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 = ...
0
votes
1answer
64 views

Exceprt not displaying

I am using a custom template homepage in which I want to display some excerpt from a category but it's not displaying as I code for just the_excerpt. I have a confusion too, they say the the_excerpt ...
-1
votes
2answers
959 views

Only display sticky post or latest post in custom loop

I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops. I want to first loop to only ever show 1 post: either a sticky post, or the ...
0
votes
0answers
248 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
237 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
69 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
78 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 ...