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
2answers
645 views

Display post thumbnail for specific category outside the loop

I'm building a theme that features a section wherein I'd like to have the single most recent post's thumbnail of a single category displayed between the header and blog sections. Something like ...
0
votes
1answer
293 views

Archive page…limiting posts per page

So what I have done is created a custom post type 'testimonials' and set the "has archive" option to "true" and have a PHP template file named "archive-testimonials.php". What I wan't to do is limit ...
2
votes
5answers
2k views

Get date of last update outside of loop

I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using get_the_time() but there doesn't seem to be a "loopless" ...
0
votes
1answer
97 views

Foundation modal in wordpress php loop

I'm using Foundation V4 framework within a child theme for a website. I currently have the wordpress post loop outputting all the content as per normal, for images I plan to do something a little ...
0
votes
2answers
92 views

Specific loop in Shortcode

I'm making shortcode and I'm stuck here. Here is code: add_shortcode('service-shortcode', 'service_shortcode'); function service_shortcode($atts) { extract( shortcode_atts( array( 'title' => ...
1
vote
1answer
226 views

Better way to display posts from specific categories, in a grid layout

I'm using the following code to display posts from a specific category, in a grid layout, on my home page. It works exactly how I want it to, but I keep reading that I shouldn't ever use query_posts. ...
0
votes
1answer
79 views

Custom Post Type + Category archive

I have created a WP stack with 3 post types: 1. Post (default) 2. Event 3. Place These 3 post types share the same taxonomy, that being the default WP category, here are some example categories: ...
0
votes
1answer
35 views

Calling Specific Pages with wp query Part II

I'm making one page website and I added a custom field on "Page" post type that asks "Use this page as a section:" Yes or No(with dropdown). I called all pages on template-onepage.php(custom template) ...
0
votes
1answer
137 views

Why do I get `Call to a member function have_posts() on a non-object `? [closed]

add_action( 'genesis_loop', 'be_home_loop' ); define('PER_PAGE_DEFAULT', 2); function be_home_loop(array $query = array()) { global $wp_query; wp_reset_query(); $paged = ...
2
votes
5answers
4k views

Order posts by custom field and if custom field is empty return remaining posts

I have an archive page ordered by a numeric value in a custom field. This returns the ordered posts correctly, but does not display posts that don't have a custom field. $paged = ...
0
votes
1answer
24 views

Trying to get property of non-object in shortocde

I'm having error in shortcode that "Trying to get property of non-object" on line no 130 Here is code: while ( $our_work->have_posts() ) { $our_work->the_post(); $termsArray = ...
0
votes
0answers
38 views

Loop latest posts from subdomain to main domain

If i install Wordpress in a subdomain, can i get latest posts from subdomain and dynamically show them in main domain?
0
votes
0answers
88 views

Display Users by usermeta using foreach loop with multiple relationships

I'm getting a real headache trying to sort this one out. Here's my problem: I'm working on a feature for a site that requires Users to be displayed according to their association with a common ...
0
votes
0answers
54 views

Link Button url count php and wordpress

I have a function where it behind me facebook tanned number, the more accurate it brings me a number of shares that a post had! I tried to solve the function, more is giving an error and I need help! ...
0
votes
1answer
55 views

Pagination not working with WP_QUERY

I have set up a custom loop that is working fine, but will not display the pagination links. After some searching around I've learned that the pagination links (as I've used them here anyway, but I'm ...
0
votes
1answer
175 views

Pagination in custom post type page template

I made a query for my custom post type "websites". I'm trying to get the pagination working but I'm running in some errors. I think the whole code is ok, only the part just before the end while tags. ...
0
votes
1answer
44 views

Trying to retrieve random post, getting a page

I'm trying to retrieve a random post to link to on my site. I have the following code, but the only thing that it seems to retrieve and display is a link to the homepage. Any help would be ...
0
votes
2answers
104 views

How to order by multiple fields using standard query_posts?

In our archive.php we show all the items which match our selected category. This works absolutely fine. Then we improved it by adding (just before the loop) a sort and upping the posts per page from ...
0
votes
0answers
167 views

Infinite Scroll or Load More Button to Categories Loop

I have a question that I can't solve and find no solution. I show all categories using a loop like this: <?php $args = array( 'orderby' => 'name', 'hide_empty' => true, 'order' ...
-1
votes
1answer
517 views

How to append a query string to pagination?

I would like to append 2 variables from page 2 onwards in my loop. This is my normal category page www.example.com/category/news/ This is what I would like on pages: 2, 3, 4, 5 etc ...
0
votes
1answer
61 views

Filtering by multiple conditions in the loop

I'm trying to filter the posts in my index by multiple conditions. So far I've tried with this: <?php $query = new WP_Query( array( "post__not_in" =>get_option("sticky_posts"), ...
0
votes
1answer
37 views

show latest authors blog post

how do you display the latest authors blog post? I have the below code: <?php $author = get_the_author(); $args = array( 'numberposts' => '1', 'author'=>$author ); $recent_posts = ...
0
votes
0answers
42 views

change the number of posts on the frontpage depending on screen width

My frontpage currently runs a secondary loop at the bottom of the page that shows 4 posts of a certain category. But I would like to reduce these posts to 3 when the screen width goes below 1024px. ...
0
votes
1answer
326 views

wpdb inside foreach loop only returns first result - 2 other similar cases found

@Milo Problem solved, found spaces in the array $arrname. I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key ...
0
votes
0answers
17 views

Change get_posts to loop.php suitable version

I did't know that get_posts don't work with loop.php. I already have this great loop.php file and I want to use it. I created this code: $pageposts = get_posts( array( 'relation' => ...
0
votes
0answers
13 views

Ordering in custom wordpress query

I have a custom wp query <?php $aId = get_the_ID(); $aList = new WP_Query(array( 'post_type' => 'porti', 'posts_per_page' => -1, 'meta_key' => 'aName', 'meta_value' => $aId, ...
0
votes
3answers
121 views

Carousel Loop only duplicating

I have problem with looping and WP_Query. Any idea how i can implement the multiple carouselitems please check what html output should be in html So basically one of my goal is each div have a pages ...
0
votes
1answer
176 views

Display most viewed post from last 30 days is not working correctly

I've try several different loop to display the most viewed post from the last 30 days . . However its just showing the post from 30 dasy ago . . not from the last 30 days . . not the most viewed . . ...
0
votes
1answer
22 views

Cannot reset a loop in a plugin template

I am trying to override a query in a loop which exists in other plugin. I created an extension to override that loop using a hook that exists in the plugin. The plugin query: query_posts ($args); /* ...
0
votes
2answers
64 views

WP_Query loop else statement not executing

I have two WP_query loops in my frontpage.php file: <div id="aanbod"> <div class="container-fluid section-name-cont"> <div class="container"> <div class="row"> ...
0
votes
0answers
40 views

Sorting posts to make those with post thumbnail show up first

I am trying to sort post with If have post thumbnail list posts show first(i need the posts without thumbnail to show after it) by title. $args = array( 'post_type' => 'post', 'meta_key' ...
0
votes
2answers
231 views

Hiding carousel indicators if there's only one post

I am working on a custom carousel (Wordpress + Bootstrap). The carousel is working without problems. However, I would like to hide Bootstrap carousel indicators and arrows if there is only one post. ...
1
vote
1answer
78 views

Access to Media Library

Im trying to find a way to pull random images from either a post or wordpress's built in image library. Im not sure how to query image uris from a post or the media library - is there a tag or method ...
2
votes
2answers
818 views

Modify this loop to fit my jQuery slider (slides)

I´m trying to make a slider which takes thumbnails from a certain custom post type and displays for of them for each "slide". I get the slider and thumbnails to work like they should, but I´m unsure ...
0
votes
1answer
26 views

Query Taxonomy By Page Title

What I want to do is display posts that share a taxonomy on a page with that taxonomies name. For example, a page named "PHP" would display all the of posts with the custom taxonomy "language" set to ...
0
votes
2answers
430 views

Filter by custom taxonomy slug on a custom post type

I am displaying results from a custom post type ("works") and want to optionally filter by a custom taxonomy ("genre") if that is set (i.e. if the loop is on the custom taxonomy archive template). I ...
0
votes
0answers
77 views

Does not show thumbnail in a given category

I am creating a loop with two formats for posting , one is the default post and the other is a video post using the post-format (video) . I found right here a function to capture and save thumbnail ...
0
votes
0answers
66 views

Show posts in category

I have a problem in the loop by the time I make a wp_query . What I'm trying to do : Bring only 4 random posts of the Videos category. Videos This category is the Post -Format Video type (I believe ...
-2
votes
1answer
60 views

Help with if/else loop [closed]

can you help me to add an else statement to this loop? <?php $post_type = 'post'; // <-- Post Type $tax = 'temporada'; // <-- Taxonomía $termino = get_terms($tax); $category = ...
1
vote
2answers
55 views

Loop within a loop (Again) for template

I know that the question was already asked but all the answer i found doesnt help me.. I made an HTML page that I would like to integrate in Wordpress. The integration of the theme was done properly ...
2
votes
2answers
110 views

get_the_foo() in the loop - does it perform another query?

I'm unclear on the get_the_foo() style of functions, for example get_the_permalink(). My main question is: when this is performed in The Loop, is another SQL query executed (besides the original ...
-1
votes
1answer
161 views

loop mix my child-category and parent-category

i explain the situatio I'm having: I have a blog, which on the homepage, have display the most recent post. For each post category, I have set up one specific color and icon by css. ex: for ...
1
vote
2answers
68 views

Query posts if meta key starts with

I need to find posts with a meta key that starts with the current year + the current month (i.e. 201502), but the actual value could also contain any day within that month (i.e. 20150214). The ...
0
votes
1answer
182 views

3 Posts in Loop, Show Stickies First

Okay I am starting to wonder if it is even possible to do this! As I've found very little info on the matter online. This is a fresh WP install that I've been experimenting on so that I can work in a ...
1
vote
1answer
73 views

How to prevent writing duplicate loops?

So i have some pages where i want to show my custom post type 'events' only by the last 5 posts (secondary query: WP_Query object) and some pages where i want to show all posts (for instance archive ...
1
vote
0answers
113 views

Default 'post' post type archive slug?

I have a wordpress site, which has a front-page.php rendering a custom front page, so that this template will show no matter if WP admin settings is set to static page or show posts. The default ...
0
votes
0answers
45 views

get_post_meta doesn't work with variable

The $event_count variable doesn't prints anything, what am i doing wrong? global $post; $event_count = get_post_meta($post->ID, 'eab_event-bp-group_event', true); $args = array( 'post_type' ...
0
votes
1answer
155 views

How to Display a Single Post Excerpt

Is it possible to show the excerpt for a known and single post (on the Home Page) while in the loop? I tried each of these and none of them work: <?php echo the_excerpt('10'); ?> <?php echo ...
5
votes
6answers
14k 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 ...
0
votes
1answer
138 views

Display category title and three latest post inside the category

I am looking for something very similar to this question. However, the answer provided there seems strange to me. I don't know what the arguments posts_per_page=-1 and it seems more like a hack to me ...