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
8 views

wp-admin redirecting to https, denying login

I use cloudflare via the cloudflare plugin, have SSL enabled. Enabled ssl within the wp-config.php file: define('WP_HOME','https://example.org'); define('WP_SITEURL','https://example.org'); ...
0
votes
0answers
18 views

Using an actual page for 404 instead of a template

How would I override the 404 template and fetch a whole page instead? Currently I have achieved this by doing a http request from 404.php(the 404 template) to http://example.org/error404, which in ...
0
votes
0answers
20 views

Publish specific category posts to specific pages

I'd like to have many different categories of posts. And many "blog template" pages. And when i create a new post of a specific category and see it posted only on specific pages. Is the only way by ...
0
votes
0answers
24 views

Repeating a loop after x amount of time

I'm new to Wordpress and PHP and would really appreciate a little pointer regarding a problem I can't solve: I have a Wordpress site and in my Homepage I have a section that when the page loads ...
0
votes
1answer
20 views

show category name before first posts in each category

I want sort posts in the loop by category and before first post in each category display category name. For example: Category 1 Post Post Post Category 2 Post Post Post Post ...
0
votes
1answer
49 views

While loop with bootstrap [closed]

Is it possible to do a while loop with Accordion from bootstrap ? I am trying to make a FAQ section with the repeater add pro add on from advanced custom fields. All the questions show up but they ...
0
votes
2answers
43 views

WP_Query a custom field value bringing back 0 results

I am trying to do a query to grab all the pages that have the tickbox checked "feature_on_front_page" which has the value "featured" with label "Featured". I added this checkbox with ACF. My query ...
0
votes
0answers
13 views

How to move posts in featured category on top and keep pagination

I want to move every post from category_id = 11 and 10 on top of the list and then query every other post which is only in 10th. I thought that making two loops will do the trick but there is a ...
0
votes
1answer
12 views

How to sort posts in archive loop

I need to sort posts using this loop, is an archive page (pc-archive.php) for a CTP named "PC". Tried with <?php while ( have_posts('order=desc') ) : the_post(); ?> but no luck... ...
1
vote
2answers
42 views

Exclude category by slug for for each loop

I am trying to exclude some categories from a for-loop. <?php $categories = get_categories(array('exclude' => 'apps, windows')); ?> <?php foreach ($categories as $category) : ?> ...
1
vote
2answers
52 views

Looping through posts per category gives same posts for each category

For a specific section on my website I loop through some categories and get the three latest posts in that categorie and list them. Like so: <?php $categories = get_categories(array('exclude' ...
-2
votes
0answers
18 views

How to add pagination to custom Woocommerce loop?

I am using woocommerce and need to make a new loop. This loop is working, however, some key information is left out, I need the number of products per page, and more importantly the pagination is ...
0
votes
0answers
11 views

Bootstrap tabs inside forloop

I'm using bootstrap tabs with custom icon for each tab, I used wp_terms() to get taxonomies and with for loop print the title of them for each tab. but how can I add the specific class for each icon ? ...
0
votes
0answers
23 views

The right loop for featured posts? [on hold]

Which is the right loop to customize articles in this way? the last article, featured, with it's style followed by: the second-last and third-last articles, in the same style followed by: ...
0
votes
1answer
29 views

Get most recent post for every term in a given taxonomy type

I'm looking for an efficient way to retrieve the most recent post from every term for a given taxonomy type. I found this question, which provides the same solution I came to on my own: $terms = ...
2
votes
1answer
11 views

How to check for specific content in comments in the loop

I'm using the following conditional code to check if any comments on a given post contains a certain string. -The word 'CHANGES' in this case. I have it working if I specify the comment_ID directly, ...
3
votes
1answer
103 views

the_content and wp_link_pages

Many plugins seem to be adding a filter/action hook to the_content to display related posts, advertisements and such. The problem is I these appear before the post pagination so it the pagination is ...
0
votes
1answer
27 views

Pass the_post() as a parameter

I would like to take the following code sample <?php while ( have_posts() ) : the_post(); ?> <h2><?php the_field('title'); ?></h2> <p><?php the_field('desc'); ...
0
votes
0answers
13 views

Get posts of specific post format, extract youtube link and use ID for image thumbnail

I am looking to query four posts of which I'll display the title and the video thumbnail. Something like this maybe? $args = array( 'tax_query' => array( array( 'taxonomy' ...
0
votes
3answers
29 views

Cant insert wrapper div into index.php

I'm having an issue inserting a wrapper div into my php index file that we're using for the front page of the site. Right now it looks like this: And it needs to look like this: I'm aware this ...
0
votes
0answers
27 views

Pagination on custom post types

Pagination works in the front page but in custom post type page it doesn't appear. Post type: add_action('init', 'portfolio_register'); function portfolio_register() { $args = array( ...
1
vote
1answer
32 views

<!--nextpage--> as a shortcode within the loop?

Anyone implemented this successfully? I want to include the <!--nextpage--> within a single post loop as a shortcode. I tried to echo it, the tag shows up but the post doesn't get divided into ...
0
votes
0answers
33 views

the_title() Returns the page title instead of the post

I'm using a custom page for listing my posts, now using the loop and the_title() returns the page title instead of the posts. My loop is a simple: <?php if (have_posts()) : ?> <?php while ...
0
votes
0answers
19 views

Hide div on click from a custom post type archive [migrated]

I'm having some trouble to achieve this .. . here is my explanation: I have a custom post type archive, On click on on list, I have the postinformation displaying by fadein - which works perfectly. ...
0
votes
1answer
26 views

get_the_title() is returning results from previous loop

I'm attempting to loop thought a custom post type (artists), then each category, then another custom post type (story) which has a relationship with the artist. The issue is, the function ID ); ?> in ...
-1
votes
1answer
35 views

tax_query not working properly with get_posts

Here are my args: $args_home = array( 'post_type' => array('news', 'jobs'), 'posts_per_page' => 12, 'meta_query' => array( array( 'key' => '_thumbnail_id' ...
0
votes
1answer
20 views

How can I modify this code to iterate over an array of categories?

I'm setting up a query for a series of 12 classes that will last a week each. There will be a morning session and an evening session. I'll have two different loops in the template to break those ...
1
vote
1answer
21 views

Sanitize Custom Field Value in Meta Query

I'm using the pre_get_posts hook with meta_query args to filter an archive loop by dates. Basically, there is a custom post type of "events", and my users type in a date as a custom field for the ...
0
votes
1answer
31 views

How to exclude or filter password protected posts when using next_post_link() previous_post_link

I'm using next_post_link() and previous_post_link() in my theme. I excluded my password protected posts from the loop. They only appear if you enter the URL of this specific post. But, the problem is ...
0
votes
0answers
13 views

Using last-child to style last post in a loop [migrated]

I'm using border-bottom to add a line between posts in search results, but that leaves an extra line at the bottom of the page. I'm trying to use last-child in my style sheet to remove that extra ...
0
votes
2answers
44 views

Skip posts, but keep posts per page

I'm running through a normal loop on one of my templates, and it displays a list of upcoming events with dates. I'd like the events that have passed to stay active, but not appear in my list of posts. ...
0
votes
1answer
24 views

Give each posts in a loop a number in sequence

In my homepage, I have 10 latest posts. I want to display numbers starting from 0-9 in each post. 0 1 2 3 4 5 6 7 8 9
0
votes
0answers
11 views

problem in the loop with wp-PostViews

I'm trying to loop using the wp-PostViews plugin, my intention is that it lists the first that has larger view. The problem that is happening is that it is not listing all the posts, just those that ...
0
votes
0answers
19 views

Custom loop layout. How can I do that?

This is the structure of the loop that I want to do. There are 2 thumbs sizes: 1. thumb-square 2. thumb-tall HTML structure: <div class="main-wrap"> <div class="col-left"> ...
0
votes
0answers
8 views

Loop the index plug-in jeckpack post view

I'm trying to get my index of the loop in order list for viewing. I'm using Jetpack Post Views for this Ex: the most viewed post is first and so on. I use a custom post with namo movies , only ...
0
votes
1answer
20 views

Set Transient on CPT

When I add set_transient code to my cpt query, I get a Fatal error: Call to a member function have_posts() on string ... on line 30 Line 30 is basically: if($graduate_student_query->have_posts()) ...
0
votes
1answer
33 views

Wordpress loop not working on static front page

I have a static wordpress front page. I want the code that works on my regular blog template to work on the homepage too. Currently, it only shows one post. The code in the main index.php is this... ...
0
votes
0answers
18 views

Strange problem with wp_get_attachment_image_src database (db) query count

I have a purchased theme that has a custom WordPress loop in it that looks for image attachments via wp_get_attachment_image_src. It does this by doing the following: $image = ...
1
vote
2answers
66 views

Get next and previous 3 posts in a term in single post page

I have a the following Custom post type: episode Custom taxonomy: series sub terms real deal -> season 1, season 2, season 3, etc. The terms are hierarchical, and the entire thing is ...
0
votes
0answers
14 views

How to include posts from one category, into a separate category of posts?

How would I insert one category of featured posts into another category of posts? So, the second, fifth and eleventh are posts from a completely different category. Hope the below illustration makes ...
0
votes
0answers
12 views

Loop within category's posts

I'm trying to figure this out since a couple of days, and even though it should be a quick and easy thing, I couldn't find any workaround. I've 4 categories, and each of it has between 10 and 40 ...
0
votes
0answers
22 views

Get link to another taxonomy from a taxonomy list

I'm currently working on a site for an artists directory. I have two custom taxonomies; Artists and Artist Genre which will be tied into a custom post type of artwork. I can get a loop to list out ...
0
votes
2answers
24 views

how do i make this loop work

Apologies I am a PHp beginner and I have no idea why this loop is not working on my tag.php page any help would be welcome. <?php get_header(); ?> <div class="posts"><!-- BLOG --> ...
-1
votes
1answer
16 views

How to do query_posts on tags pages

So I am using the tags.php on my WordPress site to create special featured pages; what I would like to do is create a featured area on the index of every page that contains the first five posts. I ...
0
votes
1answer
17 views

Multiple Loops on a Page Without Duplicates

I have tried many different versions of this and nothing seems to be working for me. I want to display single posts of a custom post type (portfolio) each in its own div. I don't want any duplicate ...
0
votes
0answers
17 views

How do I filter out certain posts from the loop while keeping total number of posts displayed the same?

I'm building a theme where a number of posts would be featured above the cut, while the rest of them would be displayed below. It's fairly easy to filter out the featured posts from the loop - I ...
0
votes
1answer
16 views

Modify loop output for a specific list of categories

I'm trying to modify the output of a loop on an archive page for a specific list of categories. Normally this loop outputs the Title, Author, Date and does so for every post in that given category. I ...
0
votes
0answers
31 views

How to make search for posts using get method?

So I am building a WordPress theme for myself to meet my needs, so what I am looking for now is make a search using a get method in PHP. If my URL is something like this : ...
4
votes
2answers
70 views

Display several random posts, but make sure a condition is met

I have a custom post type for a group of people (employees). At first, I needed to display 7 random employees. That was easy <?php $args = array( 'post_type' => 'employees', ...
0
votes
1answer
56 views

group search results by post type?

My site has 3 unique post types: Default Blog posts ("post") custom type "lesson" custom type "series" When the user searches the site, I would like pertinent results from all 3 post types to show ...