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)

2
votes
1answer
915 views

get_template_part from plugin

This is default get_template_part function inside WordPress: function get_template_part( $slug, $name = null ) { do_action( "get_template_part_{$slug}", $slug, $name ); $templates = array(); ...
0
votes
1answer
32 views

How to create content automatically when a post is published?

Goal: Ability to automatically create content in WordPress posts/pages. Goal Details: When a post is created/published, it will automatically create or configure content based on the base data inputs ...
1
vote
3answers
58 views

The Loop in Static Page

I have some questions about the loop. I'm using "twentyfourteen" theme as an example. I'm creating 2 php files with basic loop. One is home.php, and one is a template page called sample-page.php . ...
0
votes
1answer
238 views

wpdb inside foreach loop only returns first result - 2 other similar cases found

@Milo Problem solved, found spaces in the array $arrname. I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key ...
0
votes
1answer
22 views

Add Class according to the order of appearance

My loop returns five posts and the HTML should look like this.. <ul> <li class="topfive"> ... </li> <li class="topfive"> ... </li> <li class="topfive"> ...
0
votes
1answer
680 views

A two column loop with one lead post

I got a loop from internet (I forgot the site) for two column post view. It has a nice CSS for it too. But skipping that for the question now. <?php $counter = 1; ?> <?php ...
0
votes
1answer
18 views

Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis

I've created a custom post type for employee Profiles. The one thing I can't (yet) figure out is how to make custom sidebars for each of the employee's profiles. I have figured out 2 ways to get ...
0
votes
0answers
16 views

Unable to login + Redirect loop on mobile

When I try to login to my wordpress page, I'm stuck in the loginpage without any CSS. Filling in the correct logins doesn't get me logged in. I just get redirected to that same page: ...
2
votes
0answers
66 views

Chopping up a large ajax request of around 200 posts

I've put myself into an uneasy situation, where I have roughly 200 posts I need to load in with jQuery .load(). Nothing shows up until the whole .load() has executed, of course. Takes roughly 3 to 4 ...
0
votes
2answers
31 views

Get List of all the Authors

How could i get List of all the Authors? author.php file shows the Information about Individual Author. for example: http://domain.com/author/bj that returns the Bj's Profile. if i enter ...
0
votes
0answers
8 views

Connections plugin pagination

I am currently using the Connections plugin for WP. It supports no pagination for the directory results though. I've tried putting efforts on the code to make pagination work but I found no success ...
0
votes
1answer
812 views

Adding vkontakte social “like” button to posts results in multiple buttons on first post only

I'm trying to add a VKontakte (pretty much the russian version of Facebook) "like" button to wordpress posts by placing it within the loop along with Twitter/Facebook "like/share" buttons. While this ...
2
votes
3answers
3k views

How to use a custom post type as front page?

I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type archive with the following code ...
3
votes
1answer
43 views

Add Incrementing ID to each paragraph in the_content

I need to loop through each paragraph in the_content and add an ID to each paragraph with an incremental value. function incrementparagraphs( $content ) { for ($i = 0; $i <count($content); ...
0
votes
1answer
46 views

Can't grab author info outside of the loop

I have an author box outside of the loop that is supposed to grab the name of the author, but the correct author isn't being displayed most likely because these tags only work inside the loop. What ...
0
votes
0answers
20 views

Conditional loop based on current page

I'm trying to get the loop below to display only the post with the category that reflects the given condition but it doesn't seem to work. Any Ideas on how this can be achieved? <?php if ...
0
votes
0answers
27 views

Posts are being displayed from old to new, in ascending order

I developed a site for a client using a premade theme called "Adapt". When I was developing on my own server, the blog posts were posting as they should in descending order (i.e. new to old with new ...
6
votes
3answers
4k views

Getting Post Comments for post ID using WP_Query() and a Custom Loop?

(Moderator's note: The original title was "Is there a way to get post comments by post ID on a custom loop using WP-Query()?") Hi! I'm running a custom loop using WP_Query, that only displays one ...
0
votes
3answers
2k views

Pagination not working on home page

I've a page named "share" with a complex loop that's working perfectly. This page is located at domain.com/share. Now I need to use this page as the home page, so I went to "Settings -> Reading" and ...
0
votes
2answers
27 views

Foreach displays from last to first

I created the foreach loop to display post images, but It displays them from last to first, how can I make It to displays from first to last ;) ? <?php $args = array( 'post_type' => ...
0
votes
1answer
13 views

Grab next post title in archive page

I am using a custom query on a page to display single posts from a specific category, one post per page. Here is my current query: $results = new WP_Query( array( 'post_type' => 'post', ...
0
votes
1answer
151 views

Home page loop with pagination problem

I used a loop to display posts from specific categories, then add the code for WP_Paginate plugin under that loop ... below my posts I see pagination links from 1 --> 5 , however when I press page 2 ...
0
votes
0answers
48 views

How to show related posts by category or custom post type?

I'm looking for the best way to go about creating, probably, custom post type where you can filter in the categories related to that custom post type in the sidebar. Here is the website I'm working ...
0
votes
1answer
644 views

WPML wp_query not working properly in one language

I have a wp_query for a custom post type and the custom taxonomy, the idea is top display the term name and below each term the associated posts. I have two languages Dutch & French. Query is ...
0
votes
0answers
33 views

Wordpress Custom Post Type and sort by Tags

I am currently making a custom Wordpress theme, but so far I am stuck at this little problem. I have created this custom post type. And in that page (media.php) I want to be able to click on the tags, ...
1
vote
2answers
50 views

Guidance with The Loop for CMS

Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 ...
0
votes
3answers
46 views

Sort Posts By Category?

Googled this for hours, cannot find a solution. On my theme you have a Browse page which pulls all the videos from the Custom Post Type I am working with. If a user makes 30 categories then id like ...
0
votes
1answer
70 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 ...
1
vote
0answers
32 views

WordPress Rewriting the DOM?

WordPress 3.9.1, Bones Theme. I'm setting up an archive page for regular 'ol blog posts. The theory is to wrap each post's information in a permalink. Such as: <?php if (have_posts()) : while ...
0
votes
1answer
190 views

Add File Attachment Name and URL into Javascript

I'm working on incorporating the jPlayer into our WordPress site. I don't particularly care for the two plugins that are available as our client is a bit on the technically deficient side. What we are ...
0
votes
0answers
22 views

Using Facebook Og Meta Tags in loop

On my index page, I have added a facebook share link to the individual posts. I want the sharer to uses the data from the post with the og meta tags. Can I add the OG Meta Tag into the post loop, ...
0
votes
1answer
54 views

Wordpress - thumbnail image from youtube (function and loop)

Hi :D i need show thumbnails from youtube in homepage, i have a code for wordpress in function and the loop but not working thumbnail from youtube. What can be wrong with the code? Function Code: ...
0
votes
1answer
31 views

How to make post content from each post display within the same div

Basically what I am trying to do is have the featured image of each of my posts display in rows of 3 showing only the featured image. When you click on one of the featured images, a div above the row ...
0
votes
1answer
580 views

Listing Specific Categories from Current Post with Depth

I've been on this for sometime and been having a ton of issues to find a proper way to do what I'm trying to achieve. An Example would be as follows: I have a featured Image with a rollover and I ...
0
votes
1answer
16 views

Loop Post Types with Name and Links

I'm trying to create a menu which loops through the registered custom post types and links to their archive pages. I've been able to get the list of post type names but it is not generating the ...
0
votes
1answer
759 views

Conditional two level dropdown filter for custom post type

I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a ...
1
vote
1answer
298 views

Enable infinite scroll on single.php

I have a problem similar to the author of this thread: Possible to paginate on single.php? I am trying to enable infinite scrolling on single.php. So far I successfully load an additional 1 post when ...
0
votes
1answer
17 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
23 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 ...
1
vote
2answers
815 views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > ...
3
votes
1answer
554 views

Creating nested forum loops in bbPress

I'm creating a customised forums front page for bbPress, by listing forums in a different way to the bbPress default. Essentially what I'm trying to do is replace the use of bbp_list_forums() with a ...
1
vote
1answer
1k views

Use WP_Query with have_posts()?

Is it possible to use $items = new WP_Query( $query_args ); with <?php if(have_posts()): ?> <?php while (have_posts()) : the_post(); ?> without changing the loop to be <?php ...
0
votes
1answer
21 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
21 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
41 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 ...
3
votes
5answers
16k views

Get excerpt using get_the_excerpt outside a loop

I have a code that call get_the_title() and it works, but get_the_excerpt() return empty. How can i make it work? This code is inside a plugin called "WP Facebook Open Graph protocol". Here's the ...
0
votes
1answer
708 views

Loop through Custom Post Type, and then show children within each iteration

I am currently using WP_Query to loop through a custom post type, and only showing the parent posts like so: <?php $loop = new WP_Query( array( 'post_type' => 'programs', ...
1
vote
6answers
8k views

How to get Author ID outside the loop

I can't get the post author ID outside the loop to make the get_the_author_meta work. So far I've tried different approaches: 1. $author_id=$post->post_author; 2. global $post; ...
1
vote
2answers
557 views

Loop with slider (slider not loading)

In my slider.php I have a loop that calls for a custom post type. That custom post type has a meta box for a slide url (link/title/etc). I can see the loop and everything else is working because in ...
0
votes
2answers
34 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 ...