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
3answers
13 views

Where should I use post_class()?

I am trying to learn WP Theme development. And as I have understod it is important to use "post_class()" since plugins may need to use it. But what I not understand is where I should use it? Should ...
0
votes
1answer
48 views
+50

Display Authors Comments on Profile Page

Hi I am trying to display a authors comments on their profile page (author.php) however both codes I tried, seem to display everyone's comments. Also the second code method is suppose to link to the ...
0
votes
0answers
7 views

How to get the categories from Related Posts using “Posts to Posts” plugin

Sorry if this has been answered elsewhere — if it has, I have been unable find the answer — or if this seems like a basic question. But I am trying to use the Related Posts functionality built into ...
1
vote
1answer
17 views

Define Function in functions.php or plugin and call in theme loop

I need to define a function in functions.php or a plugin and be able to call it inside the theme's loop & outside. Example; I have a $product_price = get_post_meta(get_the_ID(), 'product-price', ...
0
votes
1answer
9 views

Post Format problem

I'v tried really a lot of solutions, and the one that works, it works half a way. Inside single.php I'v added <?php while ( have_posts() ) : the_post(); ?> <?php if( ...
0
votes
1answer
731 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
0answers
6 views

Why is this custom taxonomy page showing all tags rather than the relevant tag?

I have a custom taxonomy 'keywords' which I am using to tag my custom content type 'publications'. I have a custom taxonomy-keywords.php page, and a loop of Publications using page-publications.php. A ...
0
votes
0answers
37 views

How to retrieve sticky post with Visual Composer's loop builder?

So I have a simple custom shortcode function build under Visual Composer with vc_map. <?php /** * Blog Posts * */ if( function_exists( 'vc_map_get_attributes' ) ) { $atts = ...
0
votes
1answer
61 views

Exceprt not displaying

I am using a custom template homepage in which I want to display some excerpt from a category but it's not displaying as I code for just the_excerpt. I have a confusion too, they say the the_excerpt ...
0
votes
2answers
674 views

Only display sticky post or latest post in custom loop

I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops. I want to first loop to only ever show 1 post: either a sticky post, or the ...
0
votes
0answers
20 views

Category filter with load more ajax

What I am trying to do is to do an Ajax request to filter posts on category click depending on the category id, then apply load more posts by ajax. Problem: when I fire the ajax call by clicking on ...
2
votes
1answer
2k 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
0answers
26 views

When can a template skip the loop?

I've reached another point with WordPress where something simple is stumping me. In working with an older theme, I have some page templates that do not call the loop. They simply use ...
0
votes
1answer
436 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 ...
1
vote
1answer
3k 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 ...
0
votes
1answer
2k 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
19 views

Only display videos and images in the_content() within loop

The issue I am trying to solve is within the WordPress loop, I only want video embeds or images to display, not any text. Currently, when creating a new post (Standard format) in the WordPress ...
0
votes
1answer
32 views

How to call custom single post?

newbie here playing with php stuff, wanna learn. So the problem is. I have created custom posts and data from those is shown in a widget. Now i want to create custom single posts for those custom ...
0
votes
2answers
475 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
0
votes
1answer
9 views

Get meta value when the page is a blog archive

I'm using custom metaboxes on my pages. For example: header icon. I created a page for the news on my site. I selected it as a blog archive page under Settings->Reading page. Unfortunately I can't ...
0
votes
0answers
19 views

How do I prevent an infinite-loop. wp_insert_posts + JSON

I'm downloading posts from JSON file with this code: $bands = json_decode(file_get_contents('json file url'),true); $arrayLength = count($bands); for ($i=1; $i <= $arrayLength-1; $i++) { ...
0
votes
0answers
7 views

I want to show a list of all the custom taxonomies, and under each a list of some posts that match that

Does anyone know how they might do that? I imagine it would involve getting the list taxonomies, and then iterating through them with php to, and for each taxonomy item, querying the posts and ...
0
votes
1answer
408 views

Repeating Loop on my Posts Page

I have a problem with my loop.php, it keeps on repeating posts. I'm guessing this might be controlled outside of this loop.php as it happens no matter what I try. Could someone please advise me as to ...
0
votes
2answers
469 views

How do I exclude posts by custom field value?

I need to exclude posts that have a custom field 'city' value of 'Melbourne'. After much searching I think the solution might consist of 2 parts. In functions.php : A function to get the post IDs ...
0
votes
0answers
8 views

Category page that displays 3 posts from each subcategory

Alright, so my main menu I am adding category "MainCat" that has subcategories i.e "SubCatOne" "SubCatTwo" etc.. When I click on that page I see all posts from all categories on it, unorganised (below ...
0
votes
1answer
15 views

WP_Query secondary query failing

I'm needing a couple queries on front-page.php and am at a loss why this is not working. My first query works fine, however, my second one specifying the category (or even nothing at all) never ...
0
votes
1answer
715 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
1answer
27 views

numberposts not responding to wp_reset_postdata()

I am working on a loop where I want the content (from 2 separate categories) to be displayed like this: 1 large format post, 1 random product, 2 small format posts, 1 feature post ...repeat. In order ...
0
votes
0answers
7 views

Loop using selection field to display content ACF

I 'm trying to create a loop to show only the contents of a multiple choice selection I have in the ACF ! I tried to do the consultation via WP_QUERY as explained in the ACF site , more does not work! ...
0
votes
0answers
17 views

Problem with pagination in custom loop on front page - no back link

I have certain problem: I have several queries on main page. When I call new WP_query on front Page (custom loop in main loop), make custom pagination, but it doest work in case if I want "Previous / ...
0
votes
1answer
23 views

Exclude first post (sticky or not) from the loop using query_posts()

I'm using query_posts( 'offset=1' ); to exclude the first post from the loop. However, if the first post is a sticky post it will be shown and the second (non-sticky) post will not be shown. Is there ...
0
votes
1answer
17 views

Returning One custom taxonomy term name

I have a custom taxonomy called cities and right now the only city is las vegas. I am trying to use the code in question to echo "Las Vegas" - for the posts that are associated - on the search results ...
0
votes
1answer
644 views

Offset WP_Query by negative 1

I have an event loop and I'm wondering if it's possible to offset the loop by -1, so the prev and next posts of the current post are shown. EDIT - Thanks for your comments, I think I can clarify. ...
0
votes
1answer
26 views

Tricky Custom post loop

I'm building a site using "theretailer" as a base and I cant figure out where to place code to get the loop to work for a custom post type "News"? the loop the theme uses is ...
5
votes
4answers
777 views

How to control output of custom post type without modifying theme?

I have a custom post type 'properties' that I'd like to control the HTML output for. For simplicity, let's focus on the archive view. As a basic example, here is what a loop looks like in an ...
1
vote
2answers
37 views

Should I use loop in the single.php file?

I read many tutorials, and checked many premium/free theme's source and most of them use loop in the single.php file. The single.php file only displays one post, so I think the_post() is enough, ...
0
votes
1answer
864 views

wp_query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
0
votes
2answers
24 views

Echo Most Recent Sticky Post in Loop?

I am looking to echo the most recent post in the loop of content. Only 1 post. Do I need to put some sort of parameter on the following code: if (have_posts()) : while (have_posts()) : ...
0
votes
2answers
19 views

How do I know the 'meta_key' for ordering my custom post type

I want to order my custom post type called sermons by sermon date, not the date entered. See here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters How do I know the ...
0
votes
1answer
841 views

Search.php - return number of results but cannot loop through

I have a following search.php page (this is just the code required for problem presentation). Why is my $total_results returning a number of posts found, but when I do a loop though it always print ...
0
votes
0answers
10 views

get posts of taxonomy parent?

I'm new with custom post type - taxonomy. I created a template page to show list of products in custom taxonomy but I don't know how exactly to do. Example: Category SubCategory ...
0
votes
1answer
513 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
0answers
33 views

Modify category archive page loop on functions.php

I was able to modify the query on the category archive page using global $wp_query; $args = array_merge( $wp_query->query_vars, array( 'tax_query' => array( array( ...
0
votes
3answers
390 views

Order by a meta field in query loop

I would like to sort my article from a category by a number added in a meta field. Here is the first step, I get the articles to display on the page. <?php $cat = get_post_meta( get_the_ID(), ...
-2
votes
0answers
14 views

Nested loop in a carouFredSel [migrated]

Im new with nested WP loop.I really got trouble with this and cant solve by myself coz it's beyond my skills. I want to loop <div class="groupitem"></div> which will show total 16 ...
0
votes
0answers
19 views

custom query - offset to pagination

I'm trying ot add a custom query to my pagination - category page. here is the code how it look like: <?php /** * The template used for displaying Blog loop * * Use for index/archive/search. ...
0
votes
0answers
11 views

Is there a way to query for standard post formats along with other formats in a single query?

Let say I want to query for standard post formats along with video post formats excluding all the other formats. I can imagine the query like this: $query = new WP_Query( array( 'post_type' ...
0
votes
1answer
22 views

different for loop if screen resolution < 1000px

I'm trying to have a different loop for different screen resolution... Example: one loop if my resolution is higher of 1000px widht, another one if lower of 1000px. I tried this: <div ...
0
votes
0answers
23 views

Displaying multiple custom meta fields on the fronted

I am trying to simplify how I display multiple metabox entries on my front page through a custom theme panel. As of right now I have a custom panel called explore which is programmed in my custom ...
0
votes
1answer
30 views

WP_query for posts with same post type AND same post category

I'm trying to display 'related articles', I do this now like this: <?php $exclude = get_the_ID(); $args = array( ...