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)

1
vote
2answers
409 views

Display both standard posts in a specific category along with a custom post type in a single loop?

I'm building a content slider that needs to show posts from a custom post type called "Features," and also show standard blog posts that are assigned to a "Featured" category. I'd like to do this ...
1
vote
2answers
241 views

How do I order my loop query?

I have a table in my database containing vote a tally I'm trying to order posts by. screenshot: the table I've tried something like this, which brings up all the voted posts and pagination okay but ...
1
vote
1answer
652 views

Add pagination to my custom loop [duplicate]

Any tips on fitting pagination into my loop below and I owe you a beer or two. I've worked out how to pull the top rated articles by vote from a custom plugin, and lay it out with a count, but ...
1
vote
1answer
127 views

How can I create a legend (Key) like the one in the footer on WordPress StackExchange

Ironically, Wordpress StackExchange has the perfect example of what I'm trying to do. At the foot of every page here is a key/legend of associated sites with a colour reference for each one. I need to ...
1
vote
1answer
279 views

Show css depending on activity type in BuddyPress activity-loop

I was wondering if anyone knew of a way to show specific styles to the activity loop depending on the activity type? This is what I had an idea of: function mycustom_act_type() { if ...
1
vote
2answers
6k views

How do I get the title of a category in a custom loop?

I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list. <ul class="subcats-list"> <?php $weightloss = ...
1
vote
1answer
111 views

It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?

This is the code: <?php get_template_part( 'pagination', 'bbp_replies' ); ?> <?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2'); ...
1
vote
1answer
1k views

Dynamic sidebar nav with current page highlighting

My sidebar loops through all of the child pages based on the parent page. For example, if you're in the "About" section you'll only see "About" child pages in the sidebar. My problem is that I have ...
1
vote
2answers
2k views

Content/Excerpt length control for a specific loop?

Is it possible to control the length of the content or excerpt for a specific query/loop? I have come across the following code, but this changes the length for all excerpts, I want it focused on a ...
1
vote
1answer
1k views

Paging doesn't work?

I have my own custom post type, and 15 items there. This code shows all the items: <?php $loop = new WP_Query( array( 'post_type' => 'my_post_type', 'posts_per_page' => 15 ) ); while ( ...
1
vote
1answer
653 views

Pagination Issues using WP_Paginate Plugin

So I have read more posts and articles about this issue than I care to admit and still nothing I can find works. Here is the issue - I can not get the pagination to advance and it shows all the same ...
1
vote
2answers
4k views

Strategy to get post meta for use outside the loop

I need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that ...
1
vote
1answer
10 views

Obtain page data and use regular loop

Is there a way to obtain the data from a certain page outside the regular flow, more efficiently than via get_post($id)? I know that I can get for example the title with $post = get_post($id); $title ...
1
vote
1answer
14 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
1
vote
0answers
22 views

How can I load posts starting from, and including, the current post?

I'm loading some posts using this argument: $args = array( 'category__in' => $catID, 'category__not_in' => 1, 'posts_per_page'=>10, 'date_query' => array( array( 'before' => ...
1
vote
0answers
52 views

How to show a post if was published less than two hours ago?

I want to show posts only that were posted less that 2 hours ago and have the custom field "¿directo?" with the value "Sí". These are my progresses, but they don't work: Functions.php: function ...
1
vote
1answer
44 views

List users by sum of all their posts' custom field values

So I can do this by user, individually, but I can't figure out how to put it in a foreach loop. What I want to do is output something like this: Author, Miles Where miles is the sum of every ...
1
vote
2answers
77 views

Load wordpress content in other domain

I've made some researches on google but can't get the right answer. I need to get my wordpress loops outside a domain using php file. For example: I have a website hosted with www.mysite.com using ...
1
vote
0answers
22 views

Does page.php need the loop? [duplicate]

Simple question. Does page.php need the loop? The Loop 'loops' through several pages/posts/content. However the page.php template only has 1 page. There's nothing to loop through. I noticed that ...
1
vote
1answer
28 views

How To Get Posts With A Specific Word

How to retrieve posts with a specific word in the loop. For example, I want to retrieve all posts with the title of the profile post (custom post type): ...
1
vote
2answers
26 views

Listing subpages title and content and styling the first iteration differently

So for now, every iteration looks the same and it's been a while since I dealt with php so could you help me? <?php $pages = ...
1
vote
2answers
41 views

Best way to assign post position in a news site homepage? (no categories, no sticky posts)

I'm currently redesigning a local news website. The old design used a whole lot of categories to handle the position of the content in the static homepage as in "top news", "middle box", "left box" ...
1
vote
0answers
90 views

Shortcode in posts called by ajax is not working

I am using ajax to load content of post. Functions like the_title() works fine, but unfortunately the_content() doesn't returns any shordcodes( gallery nor tablepress ) data. here is my code: ...
1
vote
1answer
70 views

Transient pagination not working properly

So I wrote the following to create a transient: $wp_object_i_created = new WP_Query('cat=1'); set_transient('category_one_posts', $wp_object_i_created, 60*60*1); Ok so then I decided "Ya know lets ...
1
vote
1answer
127 views

Modify the main loop to display current month / year

So pre_get_posts seems to be the way to do this now - a lot of the background is nicely explained here: When to use WP_query(), query_posts() and pre_get_posts I can happily modify the main loop to ...
1
vote
1answer
334 views

How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()?

I read this question but it wasn't what I was looking for exactly. I'm new to Wordpress and a little confuse with the functions and everything. How can I get the metadescription in the loop for each ...
1
vote
0answers
82 views

Checkbox doesn't stay checked, conten

I'm using the morefields plugin to create textfields and checkboxes in the dashboard. For a test I have first created a checkbox on 'pages' if it was checked, the frontend showed the text ...
1
vote
1answer
209 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 ...
1
vote
2answers
542 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 > ...
1
vote
0answers
31 views

On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)

Looking for a way to on single.php fetch and show the actual post, and then by looking on the menu_order value of that specific post (lets say the post have menu_order value 3 in this case) go and ...
1
vote
1answer
2k views

query_posts() vs get_posts() multiple loops [duplicate]

I have a template which initially had one single loop and it was using query_posts, I added 2 more loops using the same method, However after reading allot about these it was concluded that I shall ...
1
vote
3answers
104 views

wordpress loop for specific category

i have this snippet for specific category it works perfect but i want little modification to show posts by Ascending order. <?php // The Query query_posts( array ( 'category_name' => 'A', ...
1
vote
0answers
94 views

Custom post type conditional in loop

I need multiple loops on a page and have created them as such global $post; $args = array( 'numberposts' => 3, 'category' => 10 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...
1
vote
2answers
90 views

Implementing an OR statement to wordpress wp_query

I am trying to return all posts that meet the following conditions: The category must be 63 OR the post must have a value associated with the meta key named 'android_link' My current argument ...
1
vote
1answer
500 views

How to add tags (custom taxonomy) to post class css?

I am trying to figure out how to add my custom taxonomy for tags to the post class css when I already have added the custom taxonomy for categories. The code Im currently using to add the category ...
1
vote
1answer
1k views

ajax for filtering posts by category in wordpress loops

I've been looking around for a way to filter my posts on http://www.waziproject.com/wazimagazine/ without reloading the page. So my question is if anyone can help me out to turn the following into a ...
1
vote
0answers
403 views

Loop that displays PARENT PAGE & CHILD PAGE & outputs GRANDCHILD PAGE title and content

I've never posted here, but I'm tired of slapping code together. That said, I would be most appreciative if someone could help me with this. I need a page template that: outputs the PARENT PAGEs, ...
1
vote
2answers
92 views

Page-loop is looping content from custom loops on the same site. How to avoid that?

i've made a custom home-page (with a template) and i'm using three loops on this site: two category-loops and on the bottom of the site the main loop for the page (the page content). the problem is: ...
1
vote
0answers
182 views

Listing all term items alphabetically / sorting loop

I have my own custom post type and it has its own taxonomy and terms. Whenever user visits http://example.com/mytaxonomy/myterm I want the page to display all items within this term alphabetically. ...
1
vote
2answers
5k views

WooCommerce Product Page Loop - Output All Product Thumbnails

http://69.89.31.200/~horologi/shop/ I'm working on the site above and the client has requested that on the shop page, all the product information is displayed on that page, including all product ...
1
vote
0answers
408 views

Display one post from each term in a custom taxonomy

I am trying to display a list which shows one post (and information about the person posting) from each custom taxonomy term. The code I am using is as follows, but it is instead printing out EVERY ...
1
vote
1answer
63 views

How to list posts with disabled/closed comments, with pagination?

i'm interested how to display all posts (from all categories) that have closed/disabled comments? I have tried using the comments_open() function inside the loop, that works, i don't know how to ...
1
vote
0answers
62 views

Display posts with comments closed, with pagination?

i'm using a custom query, which needs to display all posts with closed comments. I have this <?php $the_query = new WP_Query('showposts=-1'); ?> <?php while ($the_query -> have_posts()) ...
1
vote
0answers
93 views

Problem getting current post tags to show in a widget

I have tried tons of examples and suggestion on this topic but I can not get them to work. What I am trying to do is display the tags associated with the current post in a widget. I have built the ...
1
vote
0answers
2k views

Display products for a category, sorted by post_excerpt

I'd like to display a list of products for a certain category, sorted by the post_excerpt. The original code I used was this: $args = array( 'tax_query' => array( array( ...
1
vote
0answers
84 views

Modified loop-single-forum.php to work inside of a sidebar Widget, not working on some site pages

So I took loop-single-forum.php, copied it and renamed it, fixed it so the site is calling the copy and then removed what I did not need from it to place it in a sidebar widget. It works beautifully ...
1
vote
1answer
357 views

Display related custom taxonomy posts in sidebar

Can I use this snippet to retrieve posts from a custom taxonomy in a custom post type? <?php $sermon_series = new WP_Query( array('series' => 'type')); ?> <?php while ...
1
vote
2answers
509 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 ...
1
vote
0answers
180 views

List authors with the last post title and order by last post date

I want to list authors with last post data and order them by last post date. Now i have this codes but i don`t know how to edit them. // Selects from tables wp_users and wp_posts, selecting published ...
1
vote
0answers
114 views

Order by category titles

I have a category page called 'features' this is all fine, but the posts in the features category also belong to a certain genre of film, and it's this what I want to order the posts by on the actual ...