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

Check to see if more than one post

I am new to php. I want to use a certain div "case" in the below code if there is one post here . If there is more than one I want to use another div "case2" <php> $connected = new WP_Query( ...
0
votes
0answers
62 views

Comments_template doesn't work

If I use comments_template(); it does not work at all. But if I change it to global $withcomments; $withcomments = 1; comments_template( 'comments.php', true ); it displays the comments ...
0
votes
1answer
37 views

get_posts() forcing ignore sticky posts on main loop

I have a custom query using get_posts() that besides ignoring sticky on its main query, ignores sticky posts on main loop. Reading around I've found that get_posts() have some trouble with sticky but ...
0
votes
1answer
31 views

what is the maximum number of post a wordpress loop can work with?

what is the maximum number of post a wordpress loop can work with? how many post can i display with 'posts_per_page' => -1? ive got 50,000+ pages and I want to sort through them, but I just get ...
0
votes
1answer
54 views

Wordpress loop is not working

Can anyone tell me why this wordpress blog is looping the header and banner over and over? It seems like instead of just looping the post it is looping the whole page. This code is inside of my ...
0
votes
2answers
40 views

Loop in taxonomy for terms and post

I'm having trouble getting this to work. I've created a custom taxonomy named article_subjects and am looping thru, displaying each term; but am trying to get the newest post for each term ...
0
votes
2answers
13 views

Get markup for post without loading into the template

I am writing a shortcode plugin that displays posts according to some parameters passed into the shortcode. I have the wp_query to get the posts and now I am trying to get the markup for the posts ...
0
votes
1answer
23 views

Why doesn't 'continue' work in page?

OK, so I'm working with a template (I have contacted the developer and they were of no help, so I'm modifying the template page as needed). The template displays portfolio items, using the following ...
0
votes
3answers
75 views

WP_Query fails despite having 1 post

I'm doing a typical custom post type query with args like this: array (size=4) 'post_type' => string 'custom_post_type' (length=15) 'post_status' => string 'publish' (length=7) ...
0
votes
1answer
43 views

Random loop with code to prevent duplicate output returns no output at all from time to time

I have a custom taxonomy with several quotes assigned to each term. Two terms (general and yoga) share the same pool of three quotes. On my front-page.php i randomly draw one quote from each term and ...
1
vote
1answer
30 views

How to use current_post to open a new unordered list every five posts

How can I add a break dynamically after 5 posts have been display to create a list of post titles? <div class="col-sm-2"> <ul> <?php $args = ...
0
votes
0answers
94 views

Filter Wordpress post Dynamically on dropdown selection?

Want to filter Wordpress post Dynamically on dropdown selection? But am not able to find out any solution how it can be done.Any help appreciated. Thanks On Clicking On Latest to Old the post ...
0
votes
0answers
37 views

Calling Custom Fields within a category loop?

What I'm trying to do is to display a specific category post listing within a page template, showing only each post's custom fields, which must be pulled and included within the following html. What I ...
1
vote
1answer
109 views

Loop - how to get previous/next post for first/last post?

I have a simple loop for a JS slider, I want to display previous and next posts titles on my slide, but I can't get previous post title on the first slide (because apparently first post have no ...
1
vote
2answers
41 views

Get_post_meta() won't return value

Ok guys... I'm sure this is going to be a really easy answer. I'm a complete noob at this. I have a custom field that is supposed to return a link. For some reason, it just redirects me back to my ...
0
votes
1answer
75 views

wp_insert_posts Fatal error: Maximum function nesting level of '100' reached, aborting!

I'm having a weird problem I have written the code as below: add_action('save_post', 'save_post_func'); function save_post_func(){ include_once(ABSPATH . WPINC . '/feed.php'); $rss = ...
0
votes
2answers
43 views

Display all images from specific CPT

I have a CPT for "Band Members", and I want to list all of them at the top of a template, above all the posts (which will just be featured images) - a sort-of Navigation for all members. I can't think ...
0
votes
1answer
62 views

Limit the number of posts from a specific category on index.php

I've had multiple requests from different clients to figure out a way to modify their blog (index.php) or Custom Post Type Archive page in order to show less posts from a certain category. A good ...
0
votes
0answers
34 views

Nested wp_query loop doesn't show connected posts

I have have a wp_query loop nested in another wp_query loop. The first loop queries the latest movies. The second loop queries the persons connected to each movie from the first loop (movies and ...
0
votes
1answer
22 views

My loop of random posts drags in comments of said random post

Hi I am setting up a random post generator so that a list of random posts from a chosen category can be displayed on a post. I also made it into a shortcode so it could be applied in an editor. THE ...
0
votes
0answers
95 views

Multiple columns + Infinite Scroll?

I am trying to create a mashable like homepage so I want to loop posts by post views using WP-PostViews plugin, and make it compatible with infinite scroll. This is the loop code I am using, taken ...
0
votes
2answers
24 views

Show the page title on blog page

I created a page for my posts, and a home.php for the structure. I would like to show the page's name on the top of the posts, but the result is always the latest post. My code: <?php ...
0
votes
0answers
54 views

Infinite scroll wont work on mobile browsers. Works on non mobile systems

I implemented infinite scroll on my WordPress blog using the following script: <script type="text/javascript"> var abc=66;//what is abc doing? $(window).scroll(function () { ...
0
votes
1answer
51 views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
0
votes
0answers
28 views

Sorting Custom Posts by Custom Field

I'm currently trying to sort custom post types called 'Donors' by the 'County' they live in. I have a custom field setup called County that they can fill in on the Donor post. Is it possible to echo ...
0
votes
0answers
15 views

Default Template infinite loop of Title

Pages which have no specific template assigned output an infinite amount of h2 page titles, which looks like this: This is what my Themes index.php looks like: get_header(); ?> Hallo ...
1
vote
2answers
174 views

Showing current subcategory

I have problem. <?php query_posts('category_name=events&posts_per_page=2&offset=1'); ?> <?php while (have_posts()) : the_post(); ?> <div> <?php $children = ...
0
votes
1answer
43 views

Can I set my WP_Query to be a Main Query?

When I create a WP_Query it's automatically considered a "secondary query", but what if I replace my main query with a WP_Query? Can I set my WP_Query to be considered a "Main Query"? The reason I ...
0
votes
3answers
44 views

Limit ads appearing more than three times

I am using the following code in content.php to repeat an ad insertion. Ads are inserted in the middle of every 2nd row in a grid of thumbnails. There are 3 thumbnails per row. <?php else : ?> ...
0
votes
1answer
59 views

Wordpress loop for multiple custom post types

I want to loop through 3 custom post types + posts and display the latest post from each. This is what I have so far. This only takes the four most recent posts but not one only from each post type. ...
0
votes
0answers
29 views

Meta box not displaying properly

I am creating a plugin that will display list of a few posts at the bottom of each post. I created a meta box which content will be displaying with the each list of posts. Problem is, if I give ...
0
votes
0answers
72 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
43 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
46 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
87 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
67 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
41 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
466 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
113 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
198 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
43 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
79 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
61 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
73 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
72 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
263 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
65 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
253 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
40 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() ) : ?> ...