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
0answers
62 views

wp_query display posts based on day

I am trying to get all posts to be displayed on a certain date. For example today Tuesday I want all posts to be displayed. It doesn't matter that the posts were created today (Tuesday) or last week ...
0
votes
0answers
35 views

WP_Query to get all posts with specified category in priority

Now I have a query to get all posts in the specific category featured. $today = date('Y-m-d'); $args = array( 'post_type' => 'event', 'event-categories' => 'featured', ...
0
votes
1answer
38 views

Featured posts and the loop

I'm trying to add a box in index.php where to show the latest 3 featured posts. According to this tutorial, I've added the following to functions.php: add_theme_support( 'featured-content', array( ...
0
votes
1answer
46 views

Why my title change the last post title in my loop?

I have a loop on my index page. The problem I'm having is that the HTML generated has a different title from what I wrote in the template part header.php in <head> I do know for sure it takes ...
0
votes
1answer
73 views

How to show the posts of some category first, and then all other

How to show the posts of some category first, and then all other posts that does not belong to that category? I have logic that get the category and reorder the posts. But i don't know how to use. ...
3
votes
1answer
63 views

Changing behavior of the loop twice in one page

I'm trying to set up a wordpress blog. I have one loop with featured posts, that pulls from the 'Featured' category and displays a slider of prominent posts. Below that, I have the regular feed of ...
0
votes
1answer
40 views

Load different template for CPT (in loop) in my plugin?

I'm writing a plugin that register a new CPT named "sec-feature". In the following loop in my index.php, I want to load a feature-template.php for this CPT posts. But get_template_part just locate for ...
0
votes
2answers
312 views

Create Array from custom post type to display a slider

I have created a custom post type in my wordpress theme dedicated to creating slides for a slider displayed on the homepage, It has a title, slide text and slide url and also featured image. I'm now ...
0
votes
2answers
99 views

Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]

I am trying to highlight the newest post in a separate layout and rest of them in a masonry index. There are 5 posts per page and I am getting the newest 5 posts on previous posts pages as well. I ...
0
votes
3answers
158 views

Display content from a specific category

I'm trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all ...
1
vote
2answers
41 views

How can I paginate this?

Been trying to use the pagination functions in wordpress with this code <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_status' => 'pending', ...
0
votes
1answer
59 views

How can I include sub-forum topics in a bbpress topic loop?

Out of the box, bbpress shows topics from a particular forum when you are on that forum's archive page. Makes sense. If that forum has a sub-forum, it will link to those sub-forums, but it won't show ...
0
votes
1answer
55 views

Including all post id's of a custom post type into an array

For my single.php (products.php), I try to build a navigation via which the user can switch between products based on the meta key "price". I want to put all id's of the products post type into an ...
0
votes
1answer
72 views

Optimize CPT-function with a loop

I want to optimize my functions of a Custom Post Type (CPT). Now I have 10 meta boxes. For each box I have an extra function. The aim is to produce the 10 boxes in one function. I already tried the ...
0
votes
1answer
71 views

Loop through posts of CatA and store value of CatB in separate array

Custom post type "Wines" has two categories: Regions & Producers. "Wines" has a value for both a Region and a Producer. I want to loop through posts in [Category => Region, Term => X] and get ...
0
votes
0answers
210 views

Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working

EDIT: So I added the full code. What I'm trying to attempt is to get the post id into the metabox values for a publish immediate and scheduled post. It appears that I'm having trouble passing the id ...
0
votes
1answer
47 views

Exclude category from get_the_category

I want to exclude a specific category from the loop, here's what I tried: Original code: // auto posts by cat if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == ...
0
votes
4answers
176 views

Getting page ID inside loop

I have a page template which has a loop to show blog posts. Inside the loop, there is get_template_part('content', 'custom') function to include the template (content-custom.php) which shows blog post ...
0
votes
2answers
36 views

Search Results Page - Displaying Custom Meta Fields

For the search results page Im making a custom template. And in that custom template I want to display custom meta field values. However, when I do this: <?php if ( have_posts() ) : ?> ...
1
vote
0answers
54 views

Custom Theme With Custom Loops

There are so many different questions on how to make pages show page numbers at the bottom but I can't seem to use the concepts explained in those to solve my own problem. I know some PHP and I've ...
1
vote
1answer
54 views

One custom loop with condition to check child posts

I have one loop of pages with 999 page ID as a parent (pages from this loop have also another child pages) $args = array( 'post_type' => 'page', 'post_parent' => 999, 'order' => 'ASC', ...
0
votes
1answer
62 views

Custom Post Type Order Index Loop

I have created a custom post type called 'events'. On the index page, I want to amend the loop to list all posts (standard and events). However, I want to order standard posts by the date it was ...
-1
votes
1answer
416 views

How to Display Post View Count

I am trying to display post view counts. I've tried below function to display the post view count, but I'm getting same post view for all the post in loop. Not getting correct post view count. ...
0
votes
0answers
97 views

Qtranslate not working on wordpress loop read more link

I have a multilingual website (English and Welsh) and I am using the qtranslate plugin. Everything works OK however I cant seem to get the 'Read more' permalink to change to the corresponding ...
0
votes
1answer
81 views

Adding specific post category between posts in loop

I'm building a site built on a masonry theme and would like to add a specific category of post ('Sponsors' in this case) after every 3rd post. An example would go: Post Post Post Sponsor Post ...
-1
votes
1answer
41 views

show custom post's post in two different divs [duplicate]

I have created a custom post type. For that I have used this code add_action( 'init', 'broker_post_type' ); function broker_post_type() { register_post_type( 'new_broker', array( 'labels' ...
0
votes
1answer
16 views

value of metadata is null wrong use of if statement

I'm using the WP-Ratings plugin which uses the Wordpress built in custom fields to save values of ratings. The name of the custom field is ratings_score. I want to ask if each post has a specific ...
-1
votes
1answer
43 views

Showing ads after posts in home page

I am using this code for showing ads after one post in the home page. It's working fine. But I want to show an ad after one post and another one ads after 5 post. What will the loop be. Any ...
0
votes
2answers
63 views

have_posts() execution failure

I wanted to create a loop which displays search results in search.php file. I followed all of the instructions in the WordPress Codex tutorial located in here: https://codex.wordpress.org/The_Loop ...
0
votes
1answer
107 views

Adding div after every two post on main loop! Why will first post not get counted?

So I am trying to add a div after every two posts in home.php and I almost followed the answer found here but changed it a bit to function with the rest of the theme. Now the problem is that in the ...
0
votes
1answer
102 views

Display single post inside accordion based on form submission results

*Note - for full background see previous question here: http://bit.ly/1gaF673 Ok, so after fixing the problem above and a couple of issues that followed. My form submission returns the results I ...
0
votes
0answers
71 views

Sorting Posts Based On Meta Value Using AJAX

I am trying to short posts on frontpage/archive pages using AJAX. The AJAX call seems okay but nothing displaying. Here is the JS: jQuery( document ).ready(function() { jQuery( ".sbyp" ...
0
votes
1answer
46 views

Wordpress Tags in class

I have added tags to my Custom Post Type. Now I want to use them to create a isotope portfolio, I can load all tags with this code: <?php $args = array( 'post_type' => 'portfolio', ...
-3
votes
2answers
46 views

What function does the loop of displaying posts?

What is the function that does the echoing of posts like post title in h1 and then the post body and then the author name. I hope everyone understood what I'm trying to say else please ask in comments ...
0
votes
0answers
13 views

Multiples Realtions with meta keys

I need multiple relations with meta keys. Bu the follow loop doesn't work. $args = array( 'post_type' => 'any', 'posts_per_page' => 5, 'meta_query' ...
0
votes
2answers
65 views

Echo array value

I have following query to store data for last week entries in database: for ( $i; $i <= 7; $i++ ) { $val[$i]= $wpdb->get_results( "SELECT COUNT(`order_total`) AS 'Total' FROM vm_orders ...
0
votes
1answer
154 views

Display post category in foreach loop with category link

I have the following code to show current author post lists with post thumbnail, post title, post date and post category. function my_get_display_author_posts() { global $authordata, $post; ...
0
votes
3answers
347 views

Use the_content outside the loop

I was trying to get first 100 words of the content in the header, and I use the following snippet to get the first 100 words in the loop, but is it possible to get the value outside the loop: ...
1
vote
1answer
116 views

Loop get_theme_mod

I've got a bunch of customizer settings set up Rather than calling individual get_theme_mod statements for each setting individually, is there a way to simplify it to loop thru them without having to ...
0
votes
1answer
85 views

setup_postdata in “loop-handling” php file called via $.ajax

I'm calling a "loop handler" kind of php file that opens a loop with WP_Query. Inside the foreach loop I want to use the show_postdata function. I'm aware of the global $post aspect of this function. ...
0
votes
1answer
103 views

get_the_excerpt() not working in plugin loop

I am new in WordPress plugin development. I am developing a simple WordPress plugin in which get_the_excerpt() not working in the loop. Other tags such as get_the_title(), get_the_permalink() even ...
0
votes
0answers
58 views

Remove entry content from homepage index with infinite scroll

I have a WP theme (built on top of Genesis) and I'm having a problem with posts that are loaded on the homepage index with infinite scroll. Essentially, I'm only showing the article title, date, ...
0
votes
0answers
74 views

How to add an empty entry to masonry?

I am using masonry js library for display posts in my wp installation. The problem with it is that you cannot really add anything between posts entries because absolute positioning is used. So either ...
0
votes
2answers
70 views

Retrieving 3 latest post from each of 5 different custom post types

I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query: $query = new WP_Query( array ( 'posts_per_page' => 15, ...
-1
votes
1answer
138 views

Excerpt all post content Content Same Size without word cutting off

On my category page there are list of 24 posts with title and excerpt content. To display specific lengths of content, I am using substr function. Now the issue is that each post excerpt content are ...
0
votes
0answers
39 views

Problems With Query and/or Template Part and/or PHP

I'm trying to show only the last article. I made content-latestnews.php and it worked before meddling with queries. Template part was shown, but after I tryed to show the actual content it would show ...
0
votes
1answer
47 views

The loop does not show users

I'm trying to show all post made ​​by the author. Code author.php <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if( get_post_type() == 'post' ) {?> <?php ...
0
votes
1answer
32 views

How to use extract shortcode in loop?

Actually I need to gallery in any new post so i use shortcode for making gallery for every new post. I use images and videos in slider. problem is that I have custom html slider need to convert ...
0
votes
1answer
286 views

Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query

When retrieving posts with wp_query how do I make the loop contain the acf fields? $args = array( 'post_type' => $postTypes, 'posts_per_page' => $numPosts, ...
0
votes
1answer
83 views

Using Wp_Query without the loop?

I want to query for posts with a certain meta value. I would use the WP_Query but when in a loop (correct me if i am wrong.. I am learning wordpress; is it only when in loop? is the the_post() that ...