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
4answers
497 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
3answers
53 views

Limit ads appearing more than three times

I am using the following code in content.php to repeat an ad insertion. Ads are inserted in the middle of every 2nd row in a grid of thumbnails. There are 3 thumbnails per row. <?php else : ?> ...
0
votes
3answers
90 views

Exclude subcategory from wp_query

I've got a simple loop, that goes through the category street-style: $street_style_tags = array( 'category_name' => 'street-style', 'posts_per_page' => 25, 'post_type' => 'post', ...
0
votes
3answers
213 views

Order by a meta fiel in query loop

I would like to sort my article from a category by a number added in a meta field. Here is the first step, I get the articles to display on the page. <?php $cat = get_post_meta( get_the_ID(), ...
0
votes
3answers
72 views

Code to check amount of blog posts and add css

Is there any sort of jquery I can use to check if there is only one blog post on the page, then to add custom CSS? And if there is more than one, add different CSS? <div class="main-blog top ...
0
votes
3answers
2k views

Pagination not working on home page

I've a page named "share" with a complex loop that's working perfectly. This page is located at domain.com/share. Now I need to use this page as the home page, so I went to "Settings -> Reading" and ...
-1
votes
3answers
61 views

Tags outside the loop

I want to display the tags of the posts in my main page. I used: global $post; the_tags(); But it's only showing up for my FIRST page.
-1
votes
3answers
122 views

AJAX in wordpress theme loop

I'm trying to make a AJAX request on my theme. I already know wordpress handle AJAX very well, but not directly on theme file. It uses admin-ajax.php for this. I working on this for a long time and ...
1
vote
2answers
77 views

Latest Post Styled Different Than other Posts

I'm just completely mixed-up with this. I need the 1st post of the loop looks differently, as a kind of magazine style, you know: bigger thumbnail and bigger title. I tried already nth-of-type in ...
1
vote
2answers
101 views

Page-loop is looping content from custom loops on the same site. How to avoid that?

i've made a custom home-page (with a template) and i'm using three loops on this site: two category-loops and on the bottom of the site the main loop for the page (the page content). the problem is: ...
1
vote
2answers
207 views

Query last updated posts (posts updated in the last 24 hours)

I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of ...
0
votes
2answers
43 views

How can I implement pagination on custom category page?

I have created a custom template page for every one of my categories. I am using a foreach loop in order to fetch the posts of this specific category in my page. if (is_page()) { ...
0
votes
2answers
59 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
2answers
82 views

Multiple instances of Featured Image Thumbnail As A Background On Homepage

Here's what I'm trying to do: Make it so the first 6 posts are displayed differently on the homepage than posts 7 and on. The first six posts should grab their featured thumbnail images and use them ...
0
votes
2answers
200 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
0
votes
2answers
92 views

have_posts() execution failure

I wanted to create a loop which displays search results in search.php file. I followed all of the instructions in the WordPress Codex tutorial located in here: https://codex.wordpress.org/The_Loop ...
0
votes
2answers
45 views

Order by multiple meta keys on wordpress

After multiple research I didn't find the correct answer to my question. I just need to order my custom post type by date and then by time (format: 18:00). Here's what I tried: ...
0
votes
2answers
181 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, ...
0
votes
2answers
60 views

Several loop in search result

I would like use two loops in the results after a search. First of all, I begin the loop if there is result <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> ...
0
votes
2answers
179 views

display all posts in current category

I am trying to display all the content/posts assigned to a certain category. I have a custom post type set up called 'Videos' and within this I have created categories called music, commercial, promo ...
0
votes
2answers
57 views

If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?

One custom post type that i've created has 5 custom fields that display specific content for a template that displays them in different areas on the page. My question is if i would have to create ...
0
votes
2answers
303 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
2answers
67 views

The Loop isn't working

I can't get the loop to work as it's supposed to, without using the not-so-recommended: <?php query_posts('post_type=post&post_status=publish&paged='. get_query_var('paged')); ?> I'm ...
0
votes
2answers
52 views

Stuck with conflicting loops on page template

I'm really new to WordPress and having a problem with my page template and a sidebar loop. I made a block that displays posts in a category in the sidebar, it also displays a custom field below the ...
0
votes
2answers
32 views

Sorting custom post types by taxonomy (So close)

I have a custom post type called 'requests' that has a custom taxonomy 'request-categories'. I've created a template with a modified loop that allows me to view my custom post type in a certain ...
0
votes
2answers
45 views

Best Way to Grab Post ID from Plugin

I'm currently using loop_end to hook my plugin and get the post id from a page. This works great, except that it's also displaying my plugin in the recent posts widget which I don't want. Is there a ...
0
votes
2answers
401 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
2answers
136 views

Showing related posts (custom post type) outside of the loop

I'm trying the following (it's a sidebar widget in the Single New template): <ul class="featured-jobs"> <?php $postid = $post->ID; $categories = ...
0
votes
2answers
120 views

Getting rid of the blog page entirely

My goal is to not use a separate blog page but end up with a structure like this... http://domain.tld/page/comments/ I believe I can do this with the Cornerstone plugin ~ [ ...
0
votes
2answers
150 views

show posts from one category with comments only

Would anybody have a good idea for getting the WP to spit out all posts from a category with (approved) comments only? I have an ecommerce site set up, and treat comments on product posts as ...
0
votes
2answers
491 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
2answers
109 views

Landing page with login

I would like to be able to force any un-registered users to the /welcome page - Currently I have set up the following: if ( trim( $_SERVER['REQUEST_URI'], '/' ) != 'welcome' && ! ...
0
votes
2answers
133 views

need help looping add_action in wp

i would like to know the proper way to do this $dynValue=5;//loop this many times //start of my loop for ($num=1; $num <= $dynValue; $num++){ //note the incremented number ($num) in the call back ...
0
votes
2answers
79 views

Paged homepage - requirements?

I've got the following loop in index.php file: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $post_per_page = 30; $do_not_show_stickies = 1; $args=array( 'post_type' => ...
-1
votes
2answers
155 views

Display Featured Image

I am having some issues trying to get featured image to appear on my front page. I am using Genesis, then genesis child theme. I only want the featured image to appear on my front-page.php. I know I ...
-1
votes
2answers
392 views

First post outside of loop, homepage only?

Because of the way my templates are structured, I need to pull the first/sticky post from the site outside of the standard loop, just on the homepage. I'm using _s (underscores.me) as a base, so the ...
-2
votes
2answers
141 views

CSS code for “inserting a custom post divider” after each post

I want to add a custom post divider to separate my posts. I'm using the Enfold theme in WordPress.org. I've searched for the answer to my question but I don't understand the coding language. I ...
-4
votes
2answers
2k views

How can I display sticky posts at first in wp_query?

I'm looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp_query code; $my_query = new WP_Query('category_name=animals&showposts=10'); while ...