Tagged Questions

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
votes
1answer
15 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
11 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
14 views

Woocoommerce stop user from purchasing products from differerent categories

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
16 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
25 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
40 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
27 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
31 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
23 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
16 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(); ?> ...
0
votes
0answers
19 views

Modify the post display in loop based on 3n+1 post [closed]

I have posts displayed in two columns in a row on blog page. I want every 3n+1 (eg: 1,4,7, etc...) post to use the full width (use entire row instead). How can I achieve something like this? Any help ...
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
17 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
41 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
12 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
31 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
23 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
20 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 [on hold]

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
26 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
12 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
26 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
21 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
32 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
25 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
24 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
29 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
38 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
55 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
51 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
23 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
30 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
29 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
74 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
16 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
30 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 ( ...
0
votes
1answer
62 views

get link of inserted media file of post within loop

inside the loop I would like to retrieve the URL of an inserted media file of each post. My attempt was: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <a href="<?php ...
0
votes
1answer
29 views

List ALL posts within last week from current category on category page

My category template shows 5 (full content) posts per page and I want to add a list of ALL the posts during the past week for that category to the top of the page as a quick overview. So the first ...
0
votes
0answers
29 views

Error Page-Template LOOP

I have this code and I want to create a page under wordpress and apply this code. I save as bcn.php file into Themes folder. I create the page and in Admin menu and apply the bcn template to the page. ...
0
votes
0answers
43 views

WP_Query Order by Specific Post ID First

I'm creating a website where I have a need to show a set of posts from a custom loop but I need to display a specific post first. This post will be dynamically specified in the URI by a $_GET ...