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
0answers
36 views

Can't find infinite loop cause

I am working on the below function which will eventually create a set of posts based on meta data entered into a "parent" post. I'm running into an infinite loop when hitting the save button, which I ...
-2
votes
1answer
37 views

How to add a continuous number to HTML tag attribute value inside The Loop [closed]

I am looking to get a result like this in my list of posts: <div data-panel="panel-1"> <!-- content --> </div> <div data-panel="panel-2"> <!-- content --> </...
1
vote
0answers
92 views

Custom Loop through category menu to include sub categories

In my custom wordpress theme I currently have the below loop to the main categories <?php $menu = wp_get_nav_menu_object('navigation'); $items = wp_get_nav_menu_items($menu->term_id); foreach($...
1
vote
1answer
30 views

Multiple Loops Inside a Function

What I understand from the CODEX, (https://codex.wordpress.org/Class_Reference/WP_Query#Multiple_Loops). then I'm trying to do a list of posts like this: <nav id="cbp-hrmenu" class="cbp-hrmenu ...
1
vote
1answer
61 views

Get a post from other loop each n-posts in the main loop

Here's the layout, I'd like to achieve. 1st row: three posts in three columns from category A 2nd row: one fullwidth post from category B 3rd row: the next three posts from category A 4th row: ...
1
vote
2answers
99 views

How to limit WP_Query to one result on the loop?

I am trying to get only one post and this needs to be the latest one so here is what I am doing: $basic_args = $wp_query->query_vars; $basic_args['tax_query'] = $wp_query->tax_query; $...
1
vote
0answers
17 views

Blog's post count cause irratic behavior

Using WP 4.4, if i set my 'max posts' in Settings > Reading = 1 , Reload blog page [which is front page] the page loads infinite 404s i have this in the start of my format.php <?php if ( !...
1
vote
2answers
59 views

Get post/page data outside the loop

I'm trying to make a mu-plugin dedicated to make OpenGraph tags for my website, since the current plugin in WP directory arent updated for ages. But i ran with several headaches trying to get post or ...
1
vote
1answer
37 views

Checking array against author id in loop

So I have a function in Wordpress with a plugin that returns a list of friends as an array. The function code is here: function friends_get_list($tmp_uid, $friend_status=1) { global $wpdb; $...
1
vote
1answer
89 views

WP_Query loop within WP_Query loop

I'm trying to use a custom WP_Query loop within another one to display data from the inner loop independently from the main loop. I found this solution but don't really understand how to use it. Here ...
0
votes
1answer
24 views

Why loop renders only last metabox from array? [closed]

The auestion is, why my foreach loop renders metabox only with information from last array? The code of class: class CusomMetaBox { /** * Hook into the appropriate actions when the class is ...
1
vote
1answer
46 views

Posts per row on archive page (custom post type)

I have problem with showing posts in more than one row, if I have more than 3 posts. How can I set more rows if I have more posts? For example, if I have 7 posts, I should have 3 rows. Can I do that? ...
1
vote
1answer
33 views

Complex query and posts pagination

I have this complex posts query, but I cant get the page navigation to work, been trying for hours with no luck, what am i missing? $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $...
2
votes
1answer
79 views

get_field not displaying my custom field value

I'm asking regarding the ACF plugin (Advanced Custom Fields) I'm working on creating a category group that will add custom fields to the category pages. These are the fields: They seem to work in ...
1
vote
0answers
50 views

Default Custom Field Value Automatically Update

I have created a hidden custom field with a php function as its value. Like so -- $value_rating = get_post_meta($Property_Id, 'vr', true); <input type="hidden" name="vr" class="form-control ...
2
votes
2answers
128 views

Automatically insert php function into post $the_content

I am trying to have 2 php functions automatically inserted in every post for my CPT. The problem I am having is that even though I've found a way to add text, Im not sure how to add the php functions ...
1
vote
1answer
36 views

Wordpress Redirects on Install

I'm having problems when trying to install wordpress on subdomain. I've downloaded the arhive from wordpress.org, unzip it on root folder and when trying to install it says I found and tryed ...
1
vote
2answers
312 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
38 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
78 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
2answers
39 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 = get_pages('child_of=...
5
votes
1answer
128 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
45 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
70 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
1answer
399 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
52 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
25 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 class="taxography-grid"><ul>...
0
votes
2answers
74 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
49 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(){ jQuery(".grid-item").first().addClass("...
0
votes
0answers
39 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: ' . count($...
2
votes
1answer
153 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
61 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
39 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
165 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
2answers
66 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
57 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
12 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
25 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
36 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
357 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
93 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
35 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 taxonomy-argomenti.php)...
-1
votes
1answer
258 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 functions-...
0
votes
1answer
171 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 taxonomy-argomenti.php)...
0
votes
1answer
37 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
166 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
76 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, manage_edit-{$cat}...
0
votes
1answer
259 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: http://goo....
0
votes
1answer
18 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 ...