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

Multiple get_posts() queries on one page

I'm building custom page template, which has some content editable through proper articles/posts. Below are those code blocks: <?php $contact = new WP_Query(); $contact = get_posts( array( 'slug' ...
0
votes
1answer
56 views

Loop with Custom Post Type and Taxonomies

Regards, i've a problem. What i want: Show a toggle with loop from Custom Post Type I create post type: Episodio And a Taxonomy: Temporada I create this loop: <?php $post_type = ...
0
votes
0answers
38 views

How to get past and upcoming post by defining date in custom field?

I have create a custom post type "event" and created some posts in it. I have also created a custom field "EventDate" and giving value like "April 08, 2011", "February 08, 2016" etc for each event ...
0
votes
0answers
43 views

2 loops with pagination on a single loop

On a page I want to always show the most recent post on top with a different layout, and have the rest of the posts listed below. So I created a template page with these 2 loops. But I cannot figure ...
0
votes
0answers
62 views

How to get Multiple Post Thumbnail in index page

I'm using this MultiplePostThumbnail plugin in my theme https://wordpress.org/plugins/multiple-post-thumbnails/screenshots/ It's working fine in all pages and in posts, problem i'm facing only on the ...
0
votes
1answer
37 views

toggle Multiple Loop with tittle

I need some help I want to list all post from a meta_key, order by meta_value in ASC order All this in 1 toogle jquery. I've this: <div id="box-temp" class="gray-shadow"> <!-- First Loop ...
1
vote
1answer
92 views

Any number in meta key (wp query)

I have such a query. The field modules_%_text is advanced custom fields flexible field where % should stand for ANY ROW number, it seams that it should work like that, however it's not. What i'm doing ...
0
votes
0answers
19 views

Posts are not showing on front page after import

I've recently importet Wordpress content from an old site to a new one, which worked fine. The problem is that those importet posts aren't showing up. I fiddled around and notices, that I need to go ...
0
votes
1answer
43 views

Custom search (wp query by custom fields)

I'm building custom search. Actually it's just need to check custom field value. The custom field is called 'summary'. However i'm not sure what i'm doing wrong as it is not working. Maybe someone ...
0
votes
0answers
39 views

Advanced Field Repeater Pagination with Custom Post

I am using a custom post type as well as advanced custom fields with a repeater. I need to somehow loop through all the repeater subfields and paginate them to 6 items per page. I have tried a few ...
0
votes
1answer
47 views

ACF field not appearing correctly in loop

There is a loop in my theme that displays posts with the following information: a title, some text, and a price. I have added a custom field to this post type using ACF. The field ID is tour_length. I ...
0
votes
1answer
40 views

Get Image tag from content of post

I have create a custom sidebar, and want to show only posts images in that sidebar. I have add a post with some text and choose image from gallery in the content of that post. Now i want to get only ...
0
votes
1answer
18 views

Display post from custom post type

I have this Custom Post Type (CPT) defined at functions.php: register_post_type( 'opinion', array( 'label' => __( 'Opiniones' ), 'singular_label' => __( ...
0
votes
1answer
50 views

More efficient way to list posts by category [duplicate]

I have a page that lists posts grouped by category. Here is the current code: <?php $cats = get_terms('category'); foreach ($cats as $cat) { $cat_id= $cat->term_id; echo ...
0
votes
0answers
38 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
1answer
120 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
72 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
1answer
44 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' ...
-1
votes
1answer
28 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 ( ...
1
vote
1answer
70 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
1answer
112 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
43 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
60 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
1answer
22 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
38 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 ...
1
vote
1answer
31 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
1answer
21 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
2answers
242 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
2answers
86 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
0answers
85 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 ...
0
votes
1answer
86 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
55 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 ...
0
votes
1answer
28 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
140 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
62 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
46 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
24 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
56 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
0answers
50 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
52 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
48 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
207 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
23 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
348 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
1answer
35 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 ...
4
votes
1answer
89 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 ...
2
votes
1answer
83 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 ...
0
votes
1answer
40 views

Secondary loop doesn't work

Hi I got a problem with my secondary loop in my template page.php. I'm trying to display some testimonials, the code that retrieve those testimonials works perfectly fine in my index.php but I won't ...
0
votes
1answer
40 views

Update status of all posts in a category

For one of my project I just want to change the post status of all the posts inside a specific category from publish to pending. It is possible to change status of multiple posts at once? I want to ...
0
votes
1answer
62 views

Stuck in the query loop

I created a two loop into my WordPress page. It should get the category name and should load all the child under the Category name. Like this ____ Cat1 ______ product 1 product 2 product 3 ____ ...