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

How does the loop know which post to view?

I think I have understood most of how to create my own themes but this one thing: How can a loop in say page.php know which page to view when it loops through all the pages on my site? If I load one ...
0
votes
1answer
32 views

WP Loop. If featured image is a panorama (3:1 ratio) execute some code

I'm wondering if there is a way to write a condition (if/else) for a featured image. If user submits a featured image in 3:1 ratio (panorama, one edge is 3 times longer than the other edge) - execute ...
0
votes
1answer
74 views

custom post type loop

If i have something like this, how should i write the loop? The first section - "img tag" first and then "div .poster-content" The second section - "div .poster-content" first and then "img tag" ...
0
votes
1answer
52 views

Add “showing posts x to x of y” in custom post type paginated loop

Is there a way that I can add "Showing posts x to x of y" into a paginated custom post type loop? So for example if I have 100 posts I'm showing 10 posts per page, on /page/3 it would show "Showing ...
0
votes
0answers
50 views

Ordering Posts by parent category, name ascending

I am currently creating a theme, and I have 2 parent categories: Budget and Brand. On home.php, I want to order all the posts ascending by their sub category name without showing the category title. ...
0
votes
2answers
97 views

How to Fix Custom Wordpress Loop with Pagination on Single Post View?

I have a custom post type called "Releases" set up and paginated perfectly using the following code: The Loop <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; $args ...
0
votes
1answer
53 views

the_content() keeps repeating itself

I'm new to Wordpress and am having trouble getting my loop to make the_content() not repeat itself. I've tried writing multiple loops as well to no avail. I mainly just want the_content() to iterate ...
0
votes
1answer
107 views

Query posts by specific word on title

Is it possible to query posts by a specific word on title? Example: I have 3 posts inside my blog and only two have the word car on the title. She wants a ride on my truck My car is super fast ...
0
votes
1answer
20 views

Using page template to fetch posts in page

i want to display posts in wp page. to do that this is what i did i created a template named mypage-page.php and copied code from page.php to mypage-page.php this is my mypage-page.php ...
1
vote
1answer
148 views

How to Filter Posts by Custom Fields?

I would like to learn the best way to filter custom post types by custom fields. In the example I am working on, I use custom taxonomies to organize my posts and filter them. I would like to add ...
-1
votes
1answer
50 views

Query wordpress posts on static page

I'm working with Wordpress theme where i need to show my posts in a static page.There is a only one section in site where we need to add posts frequently (services) and i need to fetch these posts on ...
0
votes
1answer
147 views

Store post content in a php variable and output them using for loop

I want to show the content of my post in a separate row one at a time whenever a tab is clicked. I already achieved this but the problem is, its showing the output for only the last tab. Other tabs ...
0
votes
1answer
25 views

Custom Looping of Wordpress Posts

I have been working on a Wordpress theme from few days. I want to achieve modern like layout in my theme's frontpage. But I am having no clue that how to achieve it. Now my wordpress theme loops ...
0
votes
1answer
64 views

Get post content from outside the loop with plugin shortcode usability

This is great for showing just the raw content... Get post content from outside the loop But i'd also like to apply shortcodes from various plugins to my content to affect the content. What would I ...
0
votes
1answer
41 views

Cannot implement byline into posts container in single.php

I tried inputting PHP byline code in page.php, single.php and page-sidebar.php inside of the loop, under the title. As I thought, the byline appears on pages but not on posts. Also, I noticed my ...
0
votes
1answer
66 views

Loop through two different sets of custom fields

I created a Custom Field ('custom_name') to allow content editors to specify a 'custom_name' (different from the title of the page) to any post created: custom_name - (Field type --> 'text') For a ...
0
votes
2answers
42 views

Not all posts showing in query

PHP: <?php $posts_query = new WP_Query('post_type="posts&posts_per_page=-1"'); if ($posts_query->have_posts()) : while ($posts_query->have_posts()) : $posts_query->the_post(); ?> ...
0
votes
1answer
58 views

Loop through incrementing custom fields

I created 4 custom fields for a specific page. Field type: Post Object (I grab thumbnails and titles from the posts) Field names: featured_content_1 featured_content_2 featured_content_3 ...
1
vote
2answers
553 views

How to load all pages into one page with their templates

I am learning how to work with Wordpress, and im trying to build my own website in it. Since my website is a onepages, i would like to be able to load all my pages ( they then count as sections ) to ...
0
votes
1answer
35 views

Configure query with multiple categories in a custom order?

I have a site with posts in 16 categories ("departments"). The home page is a grid of the current (newest) post in each category. I would like to create the HTML for displaying a department's ...
0
votes
0answers
78 views

All pages showing same posts

My blog is showing all the same posts (recent 10) on every paginated page. I'm trying to get it to display only the category "irl", which is working. but /page/2 etc. show the same posts.. my loop: ...
0
votes
1answer
93 views

Looping Through Custom Tax Terms and Displaying All Posts For Each

I'm using the following code to attempt to loop through each of the terms within my custom taxonomy category-film and then output the term name as a heading together with displaying all the custom ...
0
votes
2answers
96 views

Add row after three columns

on my newssite i have the first post in a full-width column, after that all older post are in three columns per row. But now i want that wordpress put after every three columns a and to keeps the ...
0
votes
0answers
45 views

Index.php Not Showing Custom Posts / Terms

I have my index.php page set up and is displaying my posts page as well as category archive pages without any issues. The problem however, is trying to display posts for custom taxonomy archives. The ...
0
votes
0answers
68 views

How to know if the search result is page?

I want to have other format to show search result if it is a page ..else do as usual <?php while ( have_posts() ) : the_post(); ?> <?php if('page' == $post->post_type)?> <?php ...
0
votes
4answers
250 views

ACF custom field in <head> [closed]

I've created an image field using Image URL via the ACF plugin. This field appears across my pages. This field enables admin to change the background image for a selected class. Here's the code I ...
0
votes
1answer
286 views

how to handle the loop using filling bootstrap grid structure?

i make a code that can fill bootstrap grid structure i used while and for loop in my code but the issue is for loop repeat its value in 2nd row the above picture tells you column 2 and 3 of first ...
0
votes
1answer
61 views

Check for the main query from the template

Besides the main loop in index.php, I'm calling several other custom queries across the theme, like this: $new_query = new WP_Query(array( // some args )); if ($new_query->have_posts()) : ...
1
vote
1answer
77 views

post loop causes wp_users and wp_usermeta DB queries for each users

Continuing my previous question: My post loop produces 2 queries per post: SELECT * FROM wp_users WHERE ID = '53' require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), ...
0
votes
0answers
34 views

Cannot Get Title or Thumbnail of Posts Page

I set up a page called 'News' and applied this as my posts page. I am really struggling, however, to output the title 'News' or the featured image that has been added to the page itself. Whenever I ...
0
votes
1answer
37 views

Foreach loop inside foreach loop?

I have a situation where only way seems to use loop inside a loop. Is that a good idea? Like everybody else, Im looking for the most optimized solution possible. Situation: I need to assing ...
0
votes
0answers
8 views

Custom template with paginated loop that returns the same posts on every page

I'm pretty frustrated right now. I've spent over 24 hours trying to make a custom template for my homepage with a custom loop (to return only featured images linked to their posts). The thing is that ...
0
votes
1answer
50 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
3answers
100 views

How to paginate this custom loop? [duplicate]

guys! I'm pretty sure this will be a piece of cake for y`all, but I'm trying to add pagination to my loop. I've tried some codes that were available around, and got to paginate it, but pages 2, 3, etc ...
-1
votes
1answer
50 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
114 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
123 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
37 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
450 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
197 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
123 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
328 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
21 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
226 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
54 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
38 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
92 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
93 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
22 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
78 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 ...