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

Recent posts headlines. How to optimize the loop

I'm using this in my page template to display the 20 recent posts headlines from category number 8, 17, 23, 423 <div id="horizontalTab"> <ul class="resp-tabs-list"> ...
1
vote
1answer
36 views

How to show Y number of custom posts after every X normal posts?

I have a loop within a loop. I figured out how to show all or X number of custom posts after Y number of normal posts. I also figured out how to show 1 custom post after every Y normal posts. How do I ...
1
vote
1answer
38 views

Custom Post Types strange pagination problem

Have a strange problem with pagination, the query work fine when I'm in homepage, but if click for the next page I get a 404 error. Disabling permalinks settings, I saw that in the query string (when ...
0
votes
0answers
29 views

Get child taxonomies in loop

Here is the structure of taxonomies what I want to display: Here is my HTML code loop: <li> <a>TAXONMOY 1</a> <div class="dropdownContainer"> <div ...
0
votes
1answer
20 views

display post tags on single.php inside loop

I want to display the tags of the current post in the single.php and do the following: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1 class="single_h"><?php ...
0
votes
0answers
8 views

Start WP Pagination From Number 1 in URL

I am using this code to paginate gallery post type images: $images = get_posts(array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post__in' => $image_ids, 'orderby' => ...
0
votes
0answers
24 views

Same date post in one box

I would like to ask for a little help. I wish you the same date is a Post;, you just enter the time of the WP. The twist, however, is that it is all in a box. I'll show it to be understood: ...
0
votes
0answers
26 views

The Loop: Not Repeating Styles [closed]

For some strange reason, my loop is not repeating my mark-up/styles consistently. My code is as follows: <script type="text/javascript"> //<![CDATA[ (function($){ //This functions first ...
0
votes
2answers
27 views

Get Value of Post before

I have a normal loop in wordpress and in every post i need to check the value of the post before to compare it with the current post. -- POST 1 -- ** DO NOTHING ** -- POST 2 -- ** GET VALUE FROM ...
0
votes
0answers
28 views

One page loop issue with posts

I have been working on this loop for a very long time. I think so far this is my best version as it will get page templates. My problem is that it does not get posts and I am not sure why. When I try ...
0
votes
1answer
21 views

Display specific posts on home page

Can someone please help me figure out if the "List category posts" plugin is the easiest solution to my problem: My goal is to be able to choose which posts are displayed on our homepage under ...
0
votes
1answer
34 views

Hook into the loop via a plugin, and output something after every X post?

I have a plugin where I want to output ads after X number of posts on the home page. The home page is step 1, but things like archives should be possible too once I get the code for the home page. ...
0
votes
1answer
14 views

loop not showing up when using a custom page template

Okay So I want to create a Custom Page Template that displays my posts exactly the same as my index.php does. You can see the code of my index.php at the bottom. So I create a .php file named ...
0
votes
1answer
61 views
+50

Custom Search Not Consistent with Results

I've set up a custom search to use the s GET variable on a URL. I want it to fetch certain results but I've come across an odd problem. First, here's my code: $search_term = $_GET['s']; ...
0
votes
0answers
18 views

Only show top level posts of specific category

I've been trying to create a loop that will only show the top level posts no children/sub category posts. Basically what my categories look like are -- -All --one --- A --- B -- ...
0
votes
3answers
88 views
+50

Pagination on Single Post

I'm looking to set up pagination on my single.php file so I can have my infinite scroll function correctly. I know that pagination can be put on a single post but I somehow need to make the single.php ...
0
votes
0answers
12 views

Filter terms bases on multiple taxonomies - operator not in? [duplicate]

Building a function for filtered taxonomies. How to use 'operator' => 'NOT IN' or 'operator' => 'IN' inside the query to only show tax_query terms that are connected to all taxonomies instead of ...
0
votes
1answer
30 views

relation OR instead of AND - Filtered term ID's in loop

Question not related anymore.. First I tought about the relation OR/ AND for results, but I believe I should work with 'operator' => 'NOT IN'. I would like to query the results that meet multiple ...
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 ...
6
votes
3answers
91 views

Can I force WP_Query to return no results?

I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The ...
0
votes
2answers
48 views

Why does `inclusive` not work in this wordpress loop?

It's seemingly simple, I have this loop which should loads posts from, and including the current post. <?php $categories = get_the_category(); foreach( $categories as $category ) { $catID[] = ...
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
1answer
17 views

How do I display the posts from a custom post type on a category.php page?

I have set up a category.php according to this wordpress hierarchy diagram. When I am on the page http://example.com/category/my-category I want to display all posts that are under my-category using ...
0
votes
1answer
38 views

Get first post from wp_query

How can I get the first post from a WP_Query result? $connected = new WP_Query( array( // Arguments )); // This doesn't work.. echo $connected[0]->post_name;
0
votes
0answers
33 views

Random posts loop order [duplicate]

I have used a loop for my theme homepage, but when I go to page 2 or 3, 4, etc., I get the same random posts in all pages. I want to make the loop generate different random posts each page. <?php ...
0
votes
2answers
42 views

Adding pagination to WP_Query [duplicate]

I've got the following loop (this is on a single page, not the index.php): $top_meta_cat_args = array( 'posts_per_page' => 9, 'post_type' => 'post', 'meta_key' => ...
0
votes
0answers
33 views

How to display all posts on one page and then open them inside a modal window

I'm working with the WordPress Bootstrap theme. I want to show all the post listing with their featured image on my page and after clicking that image I want to open the post description into a modal ...
0
votes
1answer
13 views

Custom content before post content

I am using this code to insert custom content after title and before content. How can i limit it to only "post" not pages and custom post types. function theme_slug_filter_the_content( $content ) { ...
0
votes
0answers
40 views

Using the_excerpt slows down page

My index-page is very slow (on load: 8 secs). There are only about 16 posts on that page. I found out, that removing the_excerpt() makes a big difference (on load: 1.6 sec), but I don't know why. I ...
1
vote
0answers
54 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 ...
0
votes
0answers
26 views

How to display only the posts with category that match the current page URL

I'm trying to get the loop below to display only the posts with the name that matches the current page's absolute name. E.G: if the URL of the current page is mysite.com/current, then the post to be ...
-1
votes
0answers
35 views

How To Display Categories Conditionally on “The Loop”

I'm trying to get specific categories to display, and only when a given page is displayed. I have tweaked the start of "The Loop" to look as shown below but it doesn't work. Any suggestions on how to ...
0
votes
1answer
45 views

Query Number of Loaded Posts in Loop

I'm loading posts via a query of a custom taxonomy called 'band': $args = array( 'tax_query' => array( array( 'taxonomy' => 'band', 'field' => 'slug', 'terms' ...
0
votes
1answer
23 views

Fetching posts from wordpress function in ajax

I'm trying to fetch posts in ajax. Everything is working but It is showing only one post. Please check my code and tell me if something is wrong function ag_get_posts() { global $post; $args ...
1
vote
1answer
45 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
1answer
31 views

display posts with same taxonomy term

I'm trying to display 5 related posts in the loop, those related posts being posts that share the same taxonomy value. e.g. I have a custom taxonomy set up called venues thus each post has a venue ...
0
votes
0answers
35 views

New WP_Query loop in admin causes problems

I am working on a project where I have a custom post type 'companies' and on this edit page in the Wordpress admin I have some custom made meta boxes, for saving company information, opening hours, ...
0
votes
0answers
23 views

After rewriting post type's URL, the number of queries has increased dramatically

I rewrited the URL of post type, and the main loop ( example.com/post-type/ ) generates an expensive number of queries. So I have a post type "cd" and taxonomy "artist", and the url are: ...
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 ...
0
votes
2answers
28 views

is_active-sidebar loop

So I have 4 widgets which is in large-3 columns, when they're not active I place a placeholder as user guide so the user would know where to put what. I did manage to work out the is_active but it ...
0
votes
0answers
21 views

Secondary loop cuts off at 10 posts?

I have a loop to get a tag name from the URL slug, and then show all the posts, grouped by category, that matched that tag. It works, but I recently noticed it only shows 10 posts despite my setting ...
0
votes
2answers
36 views

Return vs Echo Shortcode

Ok, so I've created a short code which echo's some of the output; the problem I discovered is that the values must be returned instead of echo'd. I'm having problems converting the shortcode to return ...
0
votes
0answers
14 views

Link to post meta page (like WordPress does for categories)

I've got a few different categories, and each has it's own page. And obviously WordPress automatically links to the category template page: category.php. However, is it possible to do this with ...
0
votes
1answer
23 views

How to add a specific div element to the first post in a row?

I was asking how to add a custom div element to the latest recent post that was uploaded. How can I do this? My code: <ul class="entrybox"> <?php $args ...
0
votes
0answers
23 views

Import rss-feed from subdomain to my tld and include it into the loop

Friends, community, i have a website with WP 3.X (MU) (www.paratodo.de) with several subdomains (for example imkerei.paratodo.de) and i want to import the articles. But i don't really want to import ...
0
votes
0answers
11 views

How to map ids of taxonomy with custom post type objects?

My wordpress installation contains of $locations (which are actually categorycourses which is a a taxonomy). foreach($locations as $location) { $categorycourses_ids_array = ...
0
votes
1answer
29 views

Genesis multiple category custom loop 404s after first page

Ok so, I have a page which shows a feed of posts in the "news" category (url is: mydomain.com/category/news ), but the client wants it to also show posts in the "press-releases" category. So in the ...
0
votes
1answer
44 views

Writing less unnecessary code with WordPress

I've got a simple homepage, that pulls content for 4 different categories. To do this, I'm writing 4 different WP_Query, and only the category name is changing (and as a result, the WP_Query name, ...
0
votes
0answers
21 views

Custom Loop Using Shortcode in Custom Page Template

I am trying to output a custom loop created using shortcode in a custom page template. Here is the code I am using to generate the shortcode: function archive_sc( $atts ) { // Attributes ...