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

Is there any difference between the_title() and echo get_the_title()?

Just a small question. Is there any difference in using <?php the_title() ?> or <?= get_the_title() ?> Yeah, I know somebody can consider using short echo tag a bad practice, I just ...
1
vote
2answers
34 views

Must Use Plugin Causing Query Error

I created an MU Plugin which will only display the posts from certain tags in the loop like this: function custom_tags( $query ) { $query->set( 'tag', array( 'custom', 'general' ) ); } ...
2
votes
1answer
39 views

Displaying Only Certain Tags in Loop

What I'm trying to do is alter the loop across my site so it will check the site URL so it will know which tag to display. For example, if I give some posts the tag "golfclubs", I want it to work ...
1
vote
0answers
13 views

Can't get WooCommerce Category to display in loop

So. I'm trying to display only a certain category on my page, but it keeps saying "no matched posts with your criteria" (only in Dutch, so forgive me if the error message is poorly translated). I'm ...
1
vote
2answers
32 views

How do I Turn This Into An if statement?

PHP noob here. I've got this query I've written to get the information of all child pages of the page you're currently on: <?php $pages = ...
4
votes
0answers
76 views

Get ID of a page containing secondary loop in content

I am trying to get the ID (outside of loop) of a page which have a loop of another CPT within its content using a shortcode. If I do a print_r of get_queried_object(), all I get the args used to ...
1
vote
1answer
14 views

custom-meta-box checkboxes from loop won't save

I tried to create a custom meta box with checkboxes, generated from a loop of a custom-post-type. I found this example here on WP Development, but I can not figure out why the boxes won't save. My ...
1
vote
1answer
30 views

Calculate all custom field values in the post loop

I have a custom post type named 'ordered_food' and the custom field named 'price', Alhough I can print out all the values, I don't know how to plus and calculate the total price. Because it's already ...
1
vote
0answers
21 views

WooCommerce free products always first in catrgory/archive loop

I needed to make some products to show POA instead of the price, so I used FREE products option and changed FREE text to POA. Now I've got a request to make those products to always be first when ...
1
vote
1answer
94 views

Pagination with 5 posts per page

I'm trying to create a paginated list of posts, and have used the Codex to write some code but I appear to be doing something wrong. These are my wp_query args $paged = ( get_query_var( 'paged' ) ) ...
0
votes
2answers
48 views

How to create posts (not post template) to be displayed on projects page?

Pages : Home - set as static home page; blog - for blog posts; About ; Contact; Projects; List of templates: front-page.php - for Home page; home.php - for blog page; about.php; contact.php; ...
0
votes
1answer
20 views

enumerating custom taxonomies?

I made this function that displays tags as an image grid function execute_taxography() { $wpbtags = get_tags(); $output.= '<div class="grid"><div ...
0
votes
2answers
68 views

How can I reduce amount of ifs and else ifs in this specific block of code?

I have some code in my loop that will determine the term in my custom taxonomy, if it's a specific term, it will output a specific image. <?php if( has_term('10', 'review-score' ) ) { ?> <a ...
0
votes
0answers
19 views

Call/link wordpress category with jquery/isotope classes

I am working on the portfolio section of my web, and these codes i have in filter.js script (in wp-includes/js folder) jQuery(document).ready(function(){ ...
0
votes
0answers
37 views

Wordpress loop uses unmodified posts array, why?

I have this code in a Wordpress template: $prepost = $post; $normal_args = array( // here goes the args ); $normal_query = new WP_Query( $normal_args ); echo 'BEFORE: ' . ...
2
votes
1answer
49 views

Make loop display posts by alphabetical order

With this loop I am displaying single posts on an archive page. The posts are being sorted by the category 'Banks'. In addition to that, how can I display them in alphabetical order? I've tried using ...
0
votes
0answers
30 views

Isotope filtering with wordpress by categories

I am using the isotope by metafizzy script, need to use it on projects page of my website, it's working fine but what i want to do is filtering by custom post categories (portfolio categories), here's ...
0
votes
1answer
27 views

Display the current post in browser as the first post in a loop (for a slideshow)

I have a custom post type - on a single page it displays all kinds of information for the post type. There are 10 posts altogether. Below the info I have a slideshow as part of a loop that displays ...
3
votes
2answers
128 views

How do I reorder (pop and push) items from WP_Query?

I have this piece of code: $normal_args = array( 'order' => 'desc', 'ignore_sticky_posts' => 1, 'meta_query' => array( array( 'key' ...
0
votes
0answers
37 views

Search by attributes or taxonomy

I'm trying to filter products by taxonomy or attributes, but I think the function has something wrong: global $woocommerce, $woocommerce_loop; $attribute = 'color-de-piel'; $values = 'Blanca'; ...
0
votes
2answers
58 views

Category page shows only 1 post when that post has more than 1 category?

The error I'm seeing is that the way I currently have my category page set up, if a post on that page has more than 1 category, the loop won't load the posts that follow the one with multiple ...
0
votes
1answer
24 views

Why the first <li> with flexslider appears as blank <li> on my code?

I have a question about flexslider, I'm working with it on Wordpress theme, but I've a problem, why te first slide appears as blank slide , I hope anyone can help me with this, the PHP code works fine ...
0
votes
0answers
7 views

Post formats in 2 columns display

I'm having a hard time trying to figure out what's wrong in my loop. Here is my loop for a 2 columns post display : <?php $i = 0; ?> <?php if (have_posts()) : while (have_posts()) : ...
0
votes
1answer
21 views

Rendering pages

I'm making a custom wordpress theme for the first time and I am having an issue. I have a static index.php file and I created page.php file which looks like this: <?php if ( have_posts() ) : ...
0
votes
1answer
29 views

Loop doesn't work

I'm making a box in my sidebar that shows with a loop a list of articles of a single category: <?php // The Query query_posts('cat=31&posts_per_page=5'); // The Loop while ( have_posts() ) : ...
0
votes
2answers
109 views

Get post id within comments loop

I have a custom comments loop on my author.php page. I am trying to get the post id so that I can echo the permalink for the post that the comment belongs to. Also so I can echo some post meta custom ...
0
votes
1answer
60 views

Problems with WP_Query, Loop, a condition and Posts per Page

I am creating a website and I have Custom Types (Plugin: Types). These Custom Types are called 'Veranstaltungen' --> they are Events. All of these Events have a starting date ( start-datum ) and an ...
0
votes
0answers
26 views

get_template_part for each level of taxonomy term w\control if empty term

before we start, thank's for your time. Structure: cpt = corsi tax = argomenti tax_term = parent tax_term_child = child tax_term_child_granchild = grandchild Current code (on ...
-1
votes
1answer
92 views

How to use add_action(“wpcf7_before_send_mail” outside wp loop?

I am trying to trigger an add_action hook (add_action("wpcf7_before_send_mail", "add_data_to_custom_table");) from outside the wordpress loop. The add_action hook is defined in theme's ...
0
votes
1answer
66 views

get_template_part for each level of taxonomy term

before we start, thank's for your time. Structure: cpt = corsi tax = argomenti tax_term = parent tax_term_child = child tax_term_child_granchild = grandchild Current code (on ...
0
votes
0answers
20 views

How to remove the most recent post from $the_query

Apologies for a very basic question: I've been searching for hours and can't find a solution. I have a Wordpress page that displays all posts of a particular custom type by using WP_Query to return ...
0
votes
1answer
77 views

get_terms() parent, child and grandchild

parent1 - child1 - grandchild1 I need to show child terms of any current term (only direct child) for each term I visit. Works only for the parent (show child1) but not for the child (doesn't show ...
0
votes
1answer
46 views

Filter existing hook using parameter and foreach loop

I am trying to create a filter to add a custom column to the edit page of any custom category that might exist in Wordpress. I am aware that the filter hook must be in the form, ...
0
votes
1answer
56 views

Alternate row and columns every X posts

Does somebody know ho to accomplish the following structure with a Wordpress loop, and repeat it for all my posts? Would be really helpful. I tried to modify the code Joshua provided here: ...
0
votes
1answer
15 views

Querying multiple categories in the WP loop if one of the category IDs is dynamically obtained

I don't know exactly where this is going wrong, but what I figure is happening is that the category I am dynamically obtaining based not the BuddyPress Group slug (post categories have matching names) ...
0
votes
0answers
16 views

multiple_loop of filterable taxonomy_portfolio for CPT

first sorry for my "school-level" english and for possible mistakes (it's the first time on this forum) I have a CPT "corso", I have more taxonomy for this CPT (argomento1, argomento2, ...) and I've ...
0
votes
1answer
34 views

Index.php is ordering posts strangely

Index.php has the loop and I'm adding HTML at intervals, but when I preview the post list page, the order is incorrect. I've tried a different loop, and I've also tried query_posts & without, but ...
0
votes
1answer
12 views

Cant pull in featured Image

I have 6 posts with a featured image set for each. I have created a template file called portfolio-template.php. I have set the portfolio page to use that template file. Inside portfolio-template.php ...
0
votes
1answer
25 views

How to execute custom loop before loop content?

How to execute custom loop before loop content? <?php remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); remove_action( 'genesis_entry_footer', ...
0
votes
0answers
21 views

Displaying no post message in rather complex query that shows only future events

I'm trying to do something rather simple, which is display a message if there are currently no posts available. However, the environment I want to do it in is rather complex, as I'm using the Types ...
0
votes
1answer
57 views

Run “the loop” in a random order

I'm using a transient to store a query that gets 60 posts and makes a mosaic of background images, because it improves performance greatly. The query has 'orderby' =>'rand' set, but obviously when ...
0
votes
0answers
22 views

Query and compare multiple meta values

The problem: I have a custom post type of 'events' which has two metaboxes: cf_eventdate and cf_eventend. The first contains the event date, in the format: 2015-11-05. The second contains the end ...
0
votes
0answers
26 views

Loop returns more items than exist?

Using the answer here: http://wordpress.stackexchange.com/a/207601/45709 exact works as it is intended. It returns 3 slides because only three slides exist. I had to slightly modify the code because ...
1
vote
1answer
39 views

How to loop over custom fields in a page template?

I was originally using a single field and things worked perfectly with the following code. Now I need to alter it to loop of several fields that are similar. To start: I've created several custom ...
0
votes
0answers
40 views

Loop through posts by category in descending date order

I am using standard posts to display news. I have three categories to assign news posts to, and a post is only ever assigned to one of these. Let's say I have post data like this: 01-Jan-2015 - ...
0
votes
1answer
65 views

How To Loop Through <li> list with Custom Post Types

Please excuse me for being ignorant. I am currently trying to learn more about PHP and WordPress. This is my first time to post a question on StackExchange. I found a jQuery plugin for a simple ...
0
votes
1answer
31 views

Get audio metadata on file upload

I am trying to fetch all audio metadata when I upload a file. This all happens in a plugin, and I currently use the add_attachment action to trigger my custom function : // link add_action( ...
0
votes
1answer
18 views

Category ID returns as '0'?

I'm trying to populate the category id from the category name within the loop. <?php $cat_name = get_theme_mod( 'cat_1' ); ?> <?php $category_id = get_cat_ID($cat_name); ?> ...
0
votes
0answers
80 views

Isotope Grid - Parent Category Filters and Subcategory Items - How?

I'm trying to develop an Isotope-based grid, with a custom post type subcategories being filtered by their parents. So the grid has filters, which are the parent categories, upon choosing a filter, ...
0
votes
0answers
17 views

Custom query . How to restore parent in custom template

I have a custom query which looks if a page has subpages and if any exists loops over childs the codes <?php // get sub pages $subPages = get_pages( array( ...