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
1answer
33 views

Custom Shortcode, functions PHP WP_Query loop

I have the following code in my functions.php file:- function featured_properties_func( $atts ) { $args = array( 'posts_per_page'=> -1, 'post_type' => 'properties', ...
1
vote
2answers
618 views

How to load all pages into one page with their templates

I am learning how to work with Wordpress, and im trying to build my own website in it. Since my website is a onepages, i would like to be able to load all my pages ( they then count as sections ) to ...
3
votes
1answer
96 views

Displaying post per day

Currently I have the code displayed below. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"> <a ...
-1
votes
1answer
53 views

Standard Loop - wp_query

I was readind this article (https://codex.wordpress.org/Class_Reference/WP_Query) and try run the Standard Loop, but I can't receive the any result. My code is this: <?php get_header(); /* ...
1
vote
1answer
49 views

Meta Key Value in current-user-only loop

I created a loop for logged-in-users-only which works perfectly for all data except for meta keys. I'd like to be able to also extract meta keys but had no luck so far. This is my loop (based on this ...
-1
votes
2answers
52 views

Tag custom loop show posts

i have a posts tag with 'php'.....i am using this code to show all posts tag with 'php' but it not work <?php query_posts('tag=$tag'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ...
5
votes
2answers
144 views

How to list some posts first in the loop based on post id

I have a query for to display some posts . $args = array( 'post_type' =>'products' 'posts_per_page'=> 12, 'orderby' => 'meta_value_num', 'meta_key' => '_price', ...
1
vote
1answer
56 views

Sort by meta key on archive page

I am trying to sort an archive page using a meta key value (which happens to be a Unix timestamp). Currently I have the posts listed on the page by their WordPress creation date. I want to use the ...
1
vote
0answers
32 views

Search form not working with custom query?

My search query doesn't seem to work, the query in my url is all correct but the content just refreshes without finding the posts with the search term.. I got a custom search query and a function to ...
1
vote
1answer
119 views

How to display all posts from standard posts to custom post types in a loop with pagination?

I have several standard posts and posts from a custom posts type. Now I want to display all of them on my home page using a loop. My problem is that it displays the posts including the posts from the ...
1
vote
0answers
53 views

Blog page Server error 500 with stick post loop in query.php

Using sticky post on site near about 5000 sticky post i have. In wp-includes/query.php here i have bellow snippet code.on line 3748 to 3760.If i comment this code the blog page work properly. if ...
1
vote
2answers
24 views

where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop

I am listing custom taxonomy names. The list is displaying and the table structure is: <table> <tr> <td>Name 1</td> <td>Name 2</td> ...
1
vote
1answer
62 views

Displaying recent post excerpts on static front page

I'm trying to display a static front page with recent posts at the bottom. Specifically, I want to display just an excerpt from the recent posts, as would be returned by the_content() if I had a ...
11
votes
2answers
6k views

Split Content and Gallery

Is there a way to split up the post content and the gallery short code. I want to display the gallery outside my normal content no matter how or where it is placed. I can use this to get the shortcode ...
1
vote
0answers
56 views

Woocommerce order query parameters IP address

I need to list all orders in a specific date and exclude ordrs from specific ip address. I know how to retrieve the order from a specific date $args = array( 'post_type' => ...
1
vote
0answers
33 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
36 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 --> ...
0
votes
2answers
2k views

Wordpress get post thumbnail url

Its simple and answered quite often: I want to get the post thumbnail variable. Even if there is a lot of input, I could not make it work for me. Here is my current code I use somewhere inside my ...
0
votes
1answer
68 views

Check for the main query from the template

Besides the main loop in index.php, I'm calling several other custom queries across the theme, like this: $new_query = new WP_Query(array( // some args )); if ($new_query->have_posts()) : ...
1
vote
0answers
72 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); ...
1
vote
1answer
29 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
2answers
85 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
1answer
55 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
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
50 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
63 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 ...
1
vote
1answer
31 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; ...
0
votes
1answer
22 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 ...
2
votes
2answers
501 views

Transient not working for custom loops

I'm working at a WordPress theme. Since I need to display featured posts, related posts, some widgets with recent posts and so on, I need to use multiple custom loops. Because of this, the number of ...
1
vote
1answer
40 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
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
1answer
32 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
64 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 ...
0
votes
1answer
95 views

Post gallery as carousel

So I have this idea in mind: I would like to create custom page template, and whenever in post gallery is between tags, for example: Lorem ipsum somethinginkgsd.... [carousel] Gallery here ...
1
vote
0answers
47 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 ...
0
votes
0answers
242 views

Sorting is not working in WordPress WP_Query

I have created a page where I am sorting the post according to the views. Here is the query: <?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query( ...
2
votes
2answers
106 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 ...
0
votes
4answers
2k 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 ...
-1
votes
2answers
591 views

Can't get the previous and next posts permalink

I tried to get the next and previous URL, and create a navigation. But it seems to only retrieve the permalink from the two first posts (but not the others recents posts). I have 5 posts (ID = 25, ...
1
vote
2answers
173 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 ...
2
votes
1answer
60 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 ...
0
votes
2answers
61 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 ...
1
vote
2answers
36 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' ) ); } ...
1
vote
0answers
40 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
38 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 = ...
5
votes
6answers
19k views

Display all posts in a custom post type, grouped by a custom taxonomy

I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the ...
1
vote
1answer
37 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
54 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
33 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
238 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' ) ) ...