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

Frontpage pagination by week

I'm trying to set up a frontpage with all the post from the current week. Well this was quiet "easy" (the query snippet): $query_string = array( 'post_type' => 'post', 'date_query' => ...
0
votes
1answer
24 views

Loop through multiple custom fields with increasing number

I have a problem with custom fields that I have been trying to figure out for a while, but with no luck. I have a section on the site I'm building that let's the users publish content form the the ...
0
votes
1answer
37 views

Get author meta data with no published posts in author.php?

Unfortunately the following codes only echo the spcefic default and custom author datas if the author has at least one published post :( <?php the_author_meta('description'); ?> <?php ...
0
votes
1answer
20 views

How wp maps urls into files

I am trying to understand how wordpress works. I have found this line of code in my theme: <?php echo get_permalink(get_option('Theme_search_page_id')) ?> If I get the that option from mysql ...
0
votes
1answer
16 views

Query pages by child term

I cannot seem to get this to work, I have tried everything I can think of and spent enough time googling, to get me to seek help elsewhere. I need to query pages in a loop, using the same taxonomy as ...
-1
votes
1answer
25 views

Custom Post Type Loop inside Array

I current have a custom post type loop: $args = array( 'post_type' => 'locations', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : ...
0
votes
1answer
13 views

How to query all custom posts of a certain type and checking what category they have

Here's what I have: Custom Post type: Vendors Vendor categories: Wedding Party Catering I want to query all Vendors and then assign them a class based on the category they are in. The class ...
-3
votes
0answers
15 views

Woocoommerce stop user from purchasing products from differerent categories [on hold]

Does anyone know/have a solution that would allow user not to buy two product from different categories. So every time a product is added to cart I would need to check if a product is already in the ...
0
votes
1answer
19 views

WP_Query for attachments without duplicating post_parent and displaying tagged image

I've tagged a number of media uploads on my site with the various products' names which are featured in them. The goal is to get a list of the posts which have been tagged with each product name, but ...
0
votes
1answer
26 views

Add something after all sticky posts in The Loop

Let's say I've got some posts and some of them are sticky. The sticky posts are displayed at the very top in The Loop. while( have_posts() ) { the_post(); get_template_part(); } How can I add ...
0
votes
1answer
41 views

Select data from database and list it in Loop (Wordpress)

your Answear helped me but i stuck again. here is what i have done now : <?PHP define( 'WP_USE_THEMES', false ); get_header(); global $wpdb; $sql = "SELECT vehicle_id, manufacturer, series, ...
0
votes
1answer
29 views

Different number of posts showing in development vs production server

So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts ...
0
votes
0answers
28 views

How to generate custom loop indexes

Besides the regular taxonomies, such as category, tag, author, archive, I also have some special indexes to display, such as list of all sticky posts, simple chronological index of all posts, top ...
0
votes
1answer
35 views

Scrolling Posts with Ajax

This is a very common question all over google , but there is a conflict between the ways we can handle this. I use this tutorial ...
0
votes
0answers
40 views

Help paginating custom loop

i'm trying to add some sort of "load more" button every X posts in this loop: <?php if(is_home()) : ?> <section class="pages clearfix"> <div ...
0
votes
0answers
24 views

Multi WP Query Problem

im using seprate multi wp query loop but first query cant return my values . anyone can help me ? $first_product = $_GET['first-product']; global $post,$wp_query; ...
0
votes
1answer
17 views

Issue with WP_Query (need a array of selected ID's)

Today I have <?php $loop = new WP_Query( array( 'post_type' => 'inspirations', 'posts_per_page' => 50 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> ...
1
vote
1answer
41 views

How to return only one instance of each, from the entire loop

I´m adding a filter function in a taxonomy archive template. The intention is to add URLs for filtering in a sidebar, and i want it to return a set of ACFs like zipcode etc... (postnr in this example ...
0
votes
1answer
19 views

Accessing Post ID Within Loop

I have a page called Products with an ID of '8' Within that, I have the following template part <?php get_template_part('loop', 'feed-products' ); ?> Then within that file, I have this ...
0
votes
1answer
42 views

Sort posts by first letter in the title not by first number

down vote favorite I have a custom post type that's used to display properties on a client website. I am sorting the posts by the title but want to ignore any numbers included in that title. so to ...
0
votes
0answers
13 views

Facebook Share Link Not Correct

I have a WordPress site that when you click the Facebook like button it likes the wrong url. If I inspect the web page, the url that is inside the like widget is always the same URL no matter what ...
0
votes
1answer
33 views

Price comparison table based on Custom Post Type?

I have created a review site where clients can rate their hosting providers based on various factors, however since the launch, many have asked if it would be possible to create a price comparison ...
0
votes
1answer
26 views

Get posts with no tags?

I have over 1000 posts with no tags. Basically I am trying to get posts with no tags to show in frontend so that users can add tags from frontend. I am using this approach in loop so as to show posts ...
6
votes
1answer
88 views

Should we trust the post globals

@toscho left a comment to this answer which had me thinking again. How much trust should he have in the global scope, specially regarding the post globals like $post. So what? The global variable ...
1
vote
3answers
24 views

the_content() seems to block my ACF-code

I have this simple code, but can't get the_content and the ACF-code to work together. If I include the_content() it blocks out the ACF-code, but if I remove the_content() the ACF-code works fine. I ...
0
votes
1answer
22 views

Advanced Post Display/Pagination/Ordering

I am working on a project that requires some advanced ordering of posts and advanced pagination. Basically, we have posts in a category, lets call this category 'mycategory'. We then have post ...
0
votes
1answer
34 views

post2post plugin - multiple connections [closed]

I am working on an existing project that requires some changes. This Worpress website uses post2post to combine some information. What I want to achieve is the following: The code is used to generate ...
1
vote
1answer
27 views

How to display different number of posts

How do I display different number of posts on the home page and archive pages, the archive pages can use the value set in the admin, but I want a custom number of posts to be displayed on the home ...
0
votes
0answers
14 views

Running posts thumbnails in flexslider

This is what i'm trying to achieve: Front page with 10 posts, with three first posts shown in a slider (flexslider) and the rest shown as regular excerpts underneath it. Ive managed to do it, this is ...
0
votes
1answer
29 views

Custom post type archive pagination with HTML5Blank theme?

Can't get the pagination to work. Here's my archive-work.php: <?php get_header(); ?> <main role="main"> <!-- section --> <section> ...
0
votes
1answer
24 views

Strange switch_to_blog() issue

OK, so WordPress has been destroying me this afternoon and this particular issue I really can't figure out. We are building a multisite network and for our particular purpose need to loop through each ...
0
votes
1answer
23 views

How do I display posts with specific value in a custom field into my loop?

I'm trying to display posts that contains a specific value from my custom field. For example, I created a custom field that asks for the year, let's say I would like to display only posts with the ...
-3
votes
0answers
40 views

WordPress Loop file

Am trying to study on loops in wordpress. The problem is that i dont want to add an other " if (have_posts()) : while (have_posts()) : the_post(); " in my files so i was looking for it in index.php ...
0
votes
0answers
37 views

Link (by categories) to the first and last posts in custom post type

Link (by categories) to the first and last posts in custom post type For a new theme, I created a “story” custom post type. The main content has a different style than the blogging part, with ...
0
votes
0answers
26 views

Archive sorted by month - separate

I was looking for my answer in this forum but without success (so far..). Case is following - I have a news page with sidebar that shows archive (last 12 months). I'm using following code: <?php ...
0
votes
2answers
28 views

WP update_post_meta link loop

I've tried to update post meta by link in loop. Here is code function make_sticky($post_id) { // Update, add, or delete field ---------------------------------- if ( get_post_meta($post_id, ...
0
votes
2answers
31 views

Change query from cat id to slug or name?

I'm using the following query to fetch posts in a category (10). I would like to change this code to use the category slug or name instead of the id number as this often changes when I move sites ...
0
votes
1answer
30 views

how can i order the category by date

This may be a quick and simple fix for someone but i want to be able to sort by 'ASC' OR 'DESC' This isn't my markup but here is the loop i want to change just not sure how. I read the query ...
0
votes
2answers
40 views

Integrating WordPress with Your Website

I am intergrating WordPress with a non WordPress site. I have installed WordPress at my evercam.io/wordpress and I have followed the codex and I have been able to display a list of posts on a static ...
0
votes
1answer
56 views

Show Posts from Single Category Not Working

I have a simple loop that outputs the content of posts and then adds some navigation links at the bottom. Wordpress is set to only show 5 posts at a time. <?php while(have_posts()) : the_post(); ...
0
votes
1answer
54 views

How to pick “full/thumbnail” images in the loop?

I am picking the latest posts through the WordPress loop using the below code, but it's picking all images at full size: if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> ...
1
vote
1answer
25 views

Inserting custom data to the_post() during loop

I have some posts on my WordPress site, and let's say I want to add a random number for each post with $num as key and random() as value. Then I want to access them with something like: $post->num ...
0
votes
1answer
25 views

Check if excerpt is empty at loop-portfolio

I want to check if excerpt is not empty, then echo the excerpt link, if not the echo permalink, like this: if(the_excerpt()!='') echo the_excerpt(); else echo get_permalink() but how can I check if ...
0
votes
2answers
32 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
0answers
34 views

Multiple Page Loops on front-page.php

Looking to build an easily editable front-page.php using multiple loops set to display pages. One way I thought about doing this was making a HOME page, then setting "About us, Services, Team" all ...
1
vote
1answer
33 views

show random image in loop if image is not set

I want to show a random image from a few options in my loop if a custom field hasn't a certain value, or it could be if it had no thumbnail. In any case, it should spit out one of the random images. ...
0
votes
1answer
82 views

Category Ajax call

I am following this post to get an ajax post filter via category to work 'Using ajax on categories and wordpress loops'. I think I have added everything in correctly as follows in my template I have: ...
0
votes
0answers
17 views

Possible to remove settings from wp_customize?

So, really basic setting here. function Ari_customize_register( $wp_customize ) { $wp_customize->add_setting('header_position', array()); $wp_customize->add_control('header_position', array( ...
0
votes
1answer
31 views

loop through posts and display inserted media and post title as a link

I'm fiddling around with an issue I cannot solve. Inside the loop I would like to find the URL of an inserted media file (pdf, doc etc) and display this as an anchor. Furthermore I would like to ...
0
votes
1answer
34 views

Custom Post Type not visible on category page

I would like to use the default category for my custom post type, but when I open the category page there's no posts there. The loop is very simple: <?php if ( have_posts() ) : while ( ...