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
153 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
74 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 ...
6
votes
4answers
14k views

Get post content from outside the loop

Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page.
1
vote
2answers
40 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
66 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
1answer
44 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 ...
5
votes
5answers
9k views

Display all posts in a custom post type, grouped by a custom taxonomy

I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the ...
0
votes
0answers
157 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
385 views

Use Click Image to Play Youtube Video in a Wordpress Loop

Here is my code on Playing Youtube Video when an image is clicked.. The HTML <div id="my-video" style="display:none;"> <div class="responsive-video"> <iframe ...
0
votes
1answer
36 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
108 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
1answer
62 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 ...
0
votes
2answers
35 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() ) : ?> ...
0
votes
2answers
206 views

ACF Query Posts by custom taxonomy field

SO I've looked at both: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/ ...
1
vote
0answers
51 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
45 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
53 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
208 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
78 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 ...
-1
votes
1answer
36 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
15 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
40 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
50 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
79 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
1answer
73 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
2answers
643 views

How to exclude specific category from the get_the_category(); array

In my loop I've added: <?php $categories = get_the_category(); $separator = ' '; $output = ''; if($categories){ foreach($categories as $category) { $output .= '<span ...
0
votes
4answers
174 views

Page template not displaying

I dont get why this isnt working. I have a custom page template, page-politics.php. It should look similar to this page: But its displaying this: Ive double, triple checked that the right ...
-1
votes
1answer
99 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
50 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
45 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', ...
0
votes
2answers
67 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, ...
0
votes
3answers
183 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: ...
-3
votes
2answers
45 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
2answers
56 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
70 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
0answers
12 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
1answer
106 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; ...
1
vote
1answer
98 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
91 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
47 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
67 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
1answer
72 views

Problem with multiple loops in wordpress theme

I am using multiple loops like this <?php $posts = get_posts('numberposts=1&order=DESC&orderby=post_date&category='.get_cat_ID( 'سیاست' )); foreach ($posts as $post) : ...
0
votes
1answer
67 views

linking to post outside the loop

Is there an easy way to link to a specific page/post outside the loop? I used the get_permalink() code as follows. <a href="<?php echo get_permalink( 164 ); ?>/post-slug/"> </a> ...
3
votes
1answer
347 views

rewind_posts() - what actually the use of it, and where using is required or preferred?

The incomplete Codex about this, says very simply: rewind_posts(): Rewind the loop posts. As per this WPSE thread, with Eugene Manuilov's answer, I got: <?php // fetch first post from the ...
0
votes
1answer
44 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
0answers
291 views

Show all posts using the template page and the loop?

I am trying to make a template page that would display all posts from all categories, in short - every post added to my website. I was googling around and found out that it can be done by using The ...
0
votes
0answers
38 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
28 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
177 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
66 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 ...