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
0answers
15 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 ...
0
votes
0answers
32 views

How can I use get_permalink() outside the loop?

I've been struggling with this question for a while and although there's some information regarding this subject I'm not sure how to implement it. My question regards sharing the current page. I am ...
0
votes
1answer
13 views

Show div only if post is in specific category

In my list of blog posts, I would like to show a div which labels the post as a "Press Release" if the post is tagged with the "Press" category. I have added the following chunk into my loop: ...
0
votes
2answers
23 views

Why am I getting posts back when I shouldnt

I have the the following variables being populated: $posts = wp_get_recent_posts(array ( 'numberposts' => 4, 'post_status' => 'publish' )); $categoryPosts = wp_get_recent_posts(array ( ...
0
votes
1answer
20 views

Why is this coming back as null? Thats wrong. There is one post

I have a category, called events. It is assigned to one post. So I created the following loop: $args = array ('category_name' => 'events', 'posts_per_page' => 4, 'orderby' => 'date', 'order' ...
0
votes
1answer
32 views

Pagination returns 404 after page 20

I got a paged loop that pulls in 4 posts per page from custom post type. It works great, with the only downside that the pagination wont go over the page/20 everything after that is 404, and the ...
0
votes
2answers
511 views

WP Query - duplicated posts once including tags in search results

I running WordPress on IIS & SQL server. As some of the plugins do not work correctly with DB ABSTRACTION I am using a lot of functions.php filters as so on. To make my search results include ...
0
votes
1answer
23 views

get_template_part for custom post type content not working

I have a custom post type of Textorial with necessary template files: textorial-type.php single-textorial.php content-textorial.php The idea is to have a custom layout for the post type and use ...
0
votes
3answers
29 views

Query & the_content() is showing in the header

This post is about two things: All the results of this query are posting to the header of the Page not on the content area as they should. Do you know of a solution as to why this is happening and ...
0
votes
0answers
21 views

WordPress ignoring LIMIT / posts_per_page despite being in wp_query

Using WP query: $myquery = new WP_Query( array( 'posts_per_page' => $instance['count'], 'meta_key' => 'mywp_post_views_count', 'orderby' => 'meta_value_num', 'order' => ...
0
votes
2answers
41 views

How to access $wp_query object from array of posts given by get_posts?

I have a simple custom query driven by get_posts: <ul> <?php $args = array('post_type' => 'event', 'numberposts' => 6 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...
0
votes
1answer
377 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
14 views

Use post in multiple places on a page with multiple posts

I have three custom post types: workouts, news_items, and business_items. I'm trying to display the top (most recent) item from each on the home page and I'm trying to put the featured picture from ...
0
votes
1answer
20 views

How to extract information from a wp_query result?

Background: I'm using a wordpress theme called skt full width. I am modifying their front page slideshow, so that it displays six random images instead of six pre-selected images. I have a custom ...
0
votes
1answer
17 views

How to get to a specific position in wp_query?

Background: I'm trying to display images in a slideshow, and I want to select those pictures randomly from the website's media. The image has a custom field in order to be selected for being the ...
0
votes
2answers
65 views

Posts in Multiple Columns and Rows with one single loop

I'm pretty new to creating my own theme and I seem to have become stuck and would really appreciate it if someone could help me. I have searched and found snippets of advice but nothing that really ...
0
votes
1answer
441 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' => ...
1
vote
0answers
18 views

Selecting specific posts with an if statement in a counted loop [migrated]

I'm currently counting the posts in the loop... <?php $count = 0; ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php $count++; ?> ...
0
votes
1answer
453 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
15 views

query_posts clarification needed

I understand for the most what query_posts does and how it works. I also know it's not good practice to use it. But I would like to know exactly what the "$posts" variable does in this setup: ...
0
votes
0answers
29 views

How can I display excerpts of my Recent posts on my static homepage?

I am using the openstrap theme. I want a static home page on my Wordpress website, I have already set this up and have a bit of content on it, the next step is I want to have atleast 4 most recent ...
1
vote
2answers
5k views

Why WP_Query('showposts=5') shows only 1 post?

I am trying to do a simple query to get the latest 5 posts into an unordered list, but this is only showing 1 result even though I have several posts. I even did an offset, but it shows the next post ...
0
votes
1answer
15 views

List all Custom Post Type posts excluding certain Taxnomy term

I'm writing a theme in which I've registered "Services" as Custom Post Type that supports "Type of Service" Custom Taxonomy. I want to list all the posts of type "Services" except those which have ...
0
votes
1answer
33 views

Function using get_posts() with tax_query not working when called from functions.php

I want to get an array of all the 'bands' in taxonomy 'types', and use the array later on in other functions etc. I have a utilities.php file that I require() in functions.php and it has the following ...
1
vote
4answers
592 views

Page template not displaying

I dont get why this isnt working. I have a custom page template, page-politics.php. It should look similar to this page: But its displaying this: Ive double, triple checked that the right ...
0
votes
1answer
21 views

Display the latest post from some selected authors

I'm building a slider that will display the latest post of a few selected authors. So far, I've written this: <?php $args = array( 'post_type' => 'post', 'posts_per_page' ...
0
votes
0answers
22 views

Might be impossible - conditional bootstrap rows in WordPress loop? Currently have 2 loops

I finally got a Bootstrap posts grid I'm happy with for this video portal site. Before I was having a lot of issues with posts never lining up correctly, or if the title above it was too long it ...
0
votes
1answer
434 views

Create a custom taxonomy template that loops through child categories in term order?

We're building a site that sells Biking Gear We're using the Genesis Theme Framework, and developing a custom child theme. It has a Custom Post Type for Products, made with the "Custom Post Type UI ...
0
votes
2answers
367 views

Display post category in foreach loop with category link

I have the following code to show current author post lists with post thumbnail, post title, post date and post category. function my_get_display_author_posts() { global $authordata, $post; ...
0
votes
1answer
25 views

Loop for sticky posts

I used Justin Tadlock's tutorial on how to create a loop consisting only sticky posts. The code looked more or less like this: $sticky = get_option( 'sticky_posts' ); rsort( $sticky ); $sticky = ...
0
votes
0answers
17 views

Multiple Post Repeat for Related Post Loop by Category

This is my code: if ( is_single() ) { $categories = get_the_category(); if ( $categories ) { foreach ( $categories as $category ) { $cat = $category->cat_ID; ...
1
vote
1answer
17 views

Accessing loop functions (e.g the_title or the_content) from post ID

I have an array of post IDs obtained through complicated filtering code. I want to display posts from these IDs, and for each post I need access to regular post functions like the_title and such. More ...
0
votes
2answers
26 views

display news with pictures 3 small and one large (loop)

I'm trying to put 4 news with pictures 3 small and one large, have gotten displaying them but the "large" is repeated with the last "small" <?php $b=1; $args = array( ...
0
votes
1answer
278 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
24 views

Blank page with custom loop

in my WordPress theme with two custom loops there is always one blank page at the end when I page through the content. E.g. when I actually have only three pages filled with content, I can access a ...
0
votes
2answers
21 views

Infinite Redirect Loop after moving to subdirectory

I installed WordPress locally and created a theme, which worked fine. Now, as I wanted to deploy the site to a webserver via FTP, I got stuck by an 301 Redirect loop which makes it impossible to ...
0
votes
1answer
23 views

How to exclude a specific categogy from a custom page template

I have a custom page template that uses the wordpress loop to display all my posts like usual: <?php if (have_posts()) : while (have_posts()) : the_post(); There is a category that I don't want ...
-1
votes
1answer
36 views

display custom post type from register taxonomy

I've created a custom post type via this function: function custom_post_type() { $labels = array( 'name' => _x( 'advertising type', 'Post Type General Name', ...
0
votes
1answer
16 views

Showing content from Wordpress ruins page CSS using WP_Query, without, content does not show

I suppose I have a two pronged issue here. I'm trying to show wordpress posts on my own site. I have a page where people can view the list of articles, then when they click on one it takes them to the ...
0
votes
1answer
338 views

Add Infinite Scroll to Ajax Loaded Category Query

Update: This has been resolved. See update below. Following a few different online tutorials, I've managed to create a function to modify my post display via Ajax based on a category selected from a ...
0
votes
1answer
53 views

How to get_template_part using AJAX?

I'm currently on the Woocommerce archive-product.php template file (say shop page or product category page). On the click of the post (or product), a GET query is added to the title of the same page, ...
0
votes
3answers
347 views

How to modify search.php to not show pages only show posts

I want to modify search.php so that it only shows posts and not pages. Can you help? Here is the loop in search.php: <?php if (have_posts()) : ?> <?php while(have_posts()): the_post(); ...
0
votes
1answer
15 views

Iterate through ID's in loop

I have created a custom loop based on category, now I would like to run a function with the specific ID of the current post being iterated through as a parameter. I have.. $secondary_loop = new ...
0
votes
1answer
682 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 ...
-2
votes
0answers
23 views

When nav button is clicked, what code is controlling which stock appears

I have a problem where an old client has had a site re-design and basically for SEO reasons the site has dropped in google, and the reason is that the home page acts as pretty much the whole site, and ...
2
votes
1answer
56 views

How to bring specific post to front of wordpress loop?

So, I have a WordPress loop going on. The below code is the template page for the woocommerce product archive page. Here's the use case for what I am trying to find out how to achieve: User is ...
3
votes
1answer
77 views

How to get order of posts?

How can I get the order through which the query is done? For example, my woocommerce product archive page is querying by ordering according to the order_by select box (as seen below). How can I get ...
0
votes
1answer
431 views

Video post format, extra content breaks video embed

I am using the content-video.php include to show the latest video post on my homepage. The include only shows the video from the post and not the rest of the content, which works well. My problem is, ...
1
vote
1answer
121 views

Custom Loop Using Shortcode in Custom Page Template

I am trying to output a custom loop created using shortcode in a custom page template. Here is the code I am using to generate the shortcode: function archive_sc( $atts ) { // Attributes ...
2
votes
1answer
8k views

How to get current post id of a custom post type in a loop using template singel-{custom type}.php?

I have a custom post type template where am looping through all post. what i am trying is when i go to my custom post page i want to get the current post id in the loop. So i tried to check if the ...