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

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
85 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
253 views

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
13 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
46 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
18 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
36 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
137 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
84 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
27 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
32 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
328 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
34 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
48 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
109 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
22 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 ) { ...
1
vote
0answers
58 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
54 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 ...
0
votes
1answer
62 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
51 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
69 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
242 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
57 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
29 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
124 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
52 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
24 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
79 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
24 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
98 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
39 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
24 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
74 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
49 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
40 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 ...
0
votes
1answer
93 views

Next / previous posts link doesn't show up with Posts 2 Posts

I am working on a Wordpress project where I use the Posts 2 Posts plugin to show posts from one post type to posts from another post type. This works great but for some reason my next_posts_link() ...
0
votes
0answers
37 views

How to exclude posts ordered by comment_count from subsequent wordpress loops using WP_Query?

My page has three separate loops on it. The first retrieves the most commented post. The query then resets for the second loop and retrieves the 3 most recent posts, then resets again to get the three ...
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
2answers
239 views

Including all terms in wordpress tax_query

I'm a little bit confused, why I can't include all the terms in tax_query automatically? My code: 'tax_query' => array( array( 'taxonomy' => 'city', 'field' => 'slug', ...
-1
votes
3answers
73 views

AJAX in wordpress theme loop

I'm trying to make a AJAX request on my theme. I already know wordpress handle AJAX very well, but not directly on theme file. It uses admin-ajax.php for this. I working on this for a long time and ...
0
votes
1answer
41 views

Insert/sticky multiple posts in multiple positions

I'm attempting to do this but with multiple posts and specific positions. The post positions are hard coded right now, but will be pulled in from post meta. This code is only being ran on the homepage ...
1
vote
0answers
35 views

Sort results by groups of numbers and letters

I have this code: <?php $letter=' '; query_posts( array ( 'orderby' => 'title', 'order' => 'ASC' ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <ul> ...
0
votes
1answer
110 views

Show multiple categories in query using redux framework variable

Stuck on trying call an option variable using the Redux Framework - that is utilizing multi-category select - inside the query. Here's what I have as my query: $the_query = new WP_Query(array( ...
1
vote
1answer
33 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
votes
1answer
134 views

posts_per_page - Repeats only first posts 'post__in' array

This question correlates with a previous question I was able to solve here: http://wordpress.stackexchange.com/a/137929/28389 I am using an array for 'post__in', and I am able to run this no problem. ...
0
votes
1answer
59 views

How to loop custom post type posts by author?

Maybe I'm not doing things the proper way, but it seems to be working very well. Also, this question title is so confusing. I don't know how to ask the question. Perhaps someone can help edit? Thanks. ...
0
votes
1answer
46 views

Remember the meta value with radio buttons

I've created a simple meta box consisting of two radio buttons: yes or no. When they click on the appropriate box, it saves the meta value to the database. However, the post page does not remember it ...
0
votes
2answers
61 views

post__in - Placing content from a foreach loop inside of an array

I know this code is incorrect, but it's a basis of what I am trying to achieve. I am parsing an xml feed via PHP and running a foreach loop to get a value from a specific key. Here is the snippet I ...
0
votes
0answers
48 views

List all wordpress categories on page loop

I'm trying to build a wordpress theme for a magazine site I plan on launching and I'm kind of stuck on a certain issue. I'm listing my posts in a 3 column layout and I'd like to create a page where I ...
0
votes
0answers
24 views

Check for new posts in the loop every x mins/seconds

I'm trying to think of a way to check for new posts in the current loop (e.g. author, or tag) using ajax to give a live blog feel without reloading the whole page. Is it possible to 'fire' the loop ...