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
0answers
10 views

Timeout error 504 with 2 query_posts , how can I make them work?

Im experiencing a error: ERROR 504 - GATEWAY TIMEOUT I have this loops that works fine IF in logged... if not, it doesn't work... Update: I have deactivated one of the query_posts and it works. ...
0
votes
0answers
13 views

Redirect loop in WP Admin with SSL

we're running a membership site on the latest Wordpress 4.5.3 hosted on Bluehost. We need to move the website to SSL so made some changes in .htaccess, wp-config.php and added Wordpress HTTPS plugin ...
-2
votes
1answer
28 views

Wrap every 2 divs in row - for each loop [on hold]

For some reason, having a bit of a nightmare wrapping every 2 divs in a row in this for each loop.... Could anyone shed any light on it at all? <?php $terms = ...
0
votes
1answer
68 views

The post order is different for logged-in and non-logged-in users? [on hold]

I noticed that for some reason on my site, the post order changes depending on whether a user is logged in or not. When I am logged in as the admin, the posts display is chronological order. But when ...
0
votes
0answers
18 views

Prevent the Loop from running on tags page

I wrote a custom post query for the tags page (tags.php), which queries all posts. I therefore do not need the Loop on that page, because it only queries those posts related to the tag. Is there any ...
0
votes
0answers
10 views

How to insert a product programmatically in DB?

I need to know what the minimum information required to insert a product in woocommerce database and make this product active in the virtual store. I need this for an API implementation in my ...
0
votes
0answers
13 views

How do I edit The Loop? - I want to change the layout etc

I know HTML and CSS but not PHP. I am trying to edit the way that the list of Posts are displayed when the visitor clicks on a category. I am using Wordpress with the Genesis Framework and the ...
0
votes
2answers
40 views

display post multiple times based on array of dates

I have a custom post type for a simple schedule list and using the meta box plugin i have two meta boxes assigned to custom post type. 1 for an image and 1 for an array of date times . In my ...
-1
votes
2answers
41 views

How to wrap every 3 posts in a div (and close the last div too) [on hold]

I have code that wraps every 3 posts in a div (so that the posts will line up horizontally even if different heights). It closes the div after 3 posts, but the problem is the div is left open if there ...
0
votes
0answers
37 views

jquery Load All Wordpress Post and Pages Into Div Using AJAX

Ok So I am working on my first Wordpress them based off html5 template that I created myself. Right Now On the site I have a continous music player. It allows the users to listen to music while ...
0
votes
1answer
57 views

pop-up lighbox with AJAX

I need to create ajax script where user choose a post type and after choose post type post show on a light-box or any thing but without loading. I can't get an idea. Please give me a idea to improve ...
0
votes
0answers
13 views

Filtering search results for nested loops

So I have a list of companies that have counties and cities. I need to be able to do something like /findmanagers/miami-dade/ and then build a query that fetches all the companies we have listed ...
0
votes
0answers
28 views

Custom Page Load by wp_query

Is there a way I can use wp_query to retrieve custom pages and posts, and display them on the front page of my WordPress site? I'd like to do that for every custom page I have, to end up with a one-...
0
votes
1answer
26 views

Dividing the loop to style post differently

I'm using a plugin that displays post and shows them in a certain area on my site, such as the sidebar or anywhere i put the <?php;?> code, but only if the author that is writing the post clicks ...
0
votes
1answer
22 views

How is WordPress changing the content markup?

In my post there is Visual and Text tabs. I've formatted some content and in the text tab it looks like this: <strong>The Mission Statement –</strong> The following is a mission ...
0
votes
1answer
26 views

Cannot retieve the_content() and the_author() - both returning empty strings

I am creating the following code to display open graph meta data in the header of my single.php page add_action('wp_head', 'mycode_add_og_meta_tags', 5); function mycode_add_og_meta_tags () { ?> ...
0
votes
0answers
24 views

Using custom query on a custom page for a custom post type

I have setup a custom page (page-mypage.php) and I want to list all posts of a custom post type when I use the loop in my custom page. I'm using pre_get_posts hook to modify the query. Problem: In ...
0
votes
1answer
27 views

Query only displays one page_id

I have a short query that is supposed to load IDs from pages that the user picks in the backend. Currently it does display an array with IDs on the frontpage, but it stops displaying posts after the ...
3
votes
1answer
40 views

Displaying custom posts only if custom meta box's date is not expired

I have a problem with displaying custom posts - I want each post to show only if a date set in a custom field has not passed. I can't figure out the where I should put the if statement in the code. ...
0
votes
1answer
40 views

How to keep a CPT stick to specific position?

I have created a CPT (esp-publicitarios) using Metabox plugin with the following code: add_filter('rwmb_meta_boxes', 'elclarin_register_meta_boxes'); function elclarin_register_meta_boxes($...
0
votes
2answers
38 views

Get Sticky User in user loop based on user role

I have this shortcode to display a loop of user avatars with order by registration date. function Profiles() { $args = array( 'orderby' => 'registered', 'order' => 'DESC', '...
0
votes
1answer
55 views

Group posts that matches a term in a loop

I'm working on a website that shows a lot of products, and this is my structure: Product (custom post type) -->Brand (custom taxonomy) ------>Brand A (custom term) ------>Brand B (custom term) -->...
2
votes
1answer
46 views

A snippet after every image

folks. I need to put a piece of code after every post image (post attached image). it's something like this: <img class="alignnone size-full wp-image-3079" src="imgurl.jpg" alt="02" width="2592" ...
2
votes
0answers
27 views

Showing random content / pictures from earlier posts in a sticky post?

I have a sticky post on my wordpress blog, in the beginning. I would like to place some random content in it, by simply replacing some HTML in the post content. The random content would come from ...
-2
votes
1answer
56 views

Get posts that matches specific terms of multiple custom taxonomies

I'm working on a page that show a lot of products. My structure is Product (custom post type) -->Brand (custom taxonomy) ------>Brand A (custom term) ------>Brand B (custom term) -->Department (...
3
votes
1answer
24 views

How to order category.php loop by 'meta_value'?

So I have a basic loop on category.php that displays all posts from the specific category, like this: <?php if (have_posts()) : while(have_posts()): the_post(); ?> <a href="<?php ...
0
votes
0answers
13 views

modifying variables passed to the Wordpress LOOP, with IF/THEN?

good evening, i'm trying to make my coding as modular as possible. my site uses three different LOOPs, each to accomplish a different task with my posts/pages, and i've got each loop on its own file, ...
0
votes
1answer
16 views

include(locate_template) messing up the loop

So, I've developed a one page theme that pulls in child pages of the parent in order create the layout. I also have it set up to pull each sub pages page template and display the content accordingly, ...
3
votes
3answers
48 views

Why does the_content not work like others for a set post id?

Here's something odd, I want to print out a certain post on any page request, if you have a constant $idnumber of your favorite page/message, then add: $GLOBALS['post'] = get_post( $idnumber ); ...
0
votes
1answer
30 views

How to hook into <head></head> container

I want to add my own <meta /> tag inside the <head></head> container on every page or post within the loop(). Is that possible? What hook(s) should I use for that?
1
vote
2answers
51 views

get latest 5 posts and a specific post and sort in a specific order

I'm looking for some advice on how to make a gallery of images. it is a particular bit a gallery, because I would show the last 5 post and a fixed post, for a total of 6 posts, in a specific order. ie ...
1
vote
0answers
82 views

Get custom post type's fields in a while loop as variables

I'm working on a page that shows the name of a lot of products (custom post type), and when the user clicks on the name he can see some product information. It's something like this: Main page with ...
0
votes
1answer
62 views

How to provide meta_key array to wp_query?

I'm trying to build a wp_query, so far I've managed to get desired result using following query. $args = array( 'meta_query' => array( 'relation' => 'OR', array( //check if ...
3
votes
1answer
53 views

What is best way passing variables to theme templates and using them different places like widgets?

I have a template file at /parts/template.php which contains a post listing code like, echo get_the_title(); //same lines with my_render_function and i am using it at archive.php with this lines. ...
0
votes
0answers
10 views

Popular posts with Varnish ESI

I am trying to get Varnish ESI to work with displaying the most viewed posts on a new blog I am working on. Here is my current script; In theme file: <esi:remove> <?php get_template_part( '...
0
votes
0answers
14 views

Retrieving category pages from subcategory returns empty sets

I've a category overview page. It shows its subcategories. These subcategories have subsubcategories which are pages too. I'd like to retrieve those (title, permalink and excerpt) but so far my ...
-1
votes
2answers
40 views

Exclude duplicated $sticky post from combined loop content

Since Wordpress sticky posts feature allow the post checked as sticky in post publish panel to be placed at the top of the front page of posts. I was also intended to style the sticky post differently ...
3
votes
2answers
43 views

Finding Page Template and Displaying Content

So, I'm building a theme for a client with one page layout functionality. Currently, I'm allowing the user to create a parent page, and the modules within that page are separate pages that will be set ...
0
votes
1answer
30 views

Querying posts from only one category and exluding the latest post

I want to run the loop so that it retrieves posts from only one particular category AND outputs only 4 posts AND excludes the latest one. To query only one category, I found this: <?php ...
4
votes
2answers
57 views

Are there any scenarios where the query_posts may be used?

I feel there is a red button saying "Do not press" below query_posts(). For some time I am trying to demystify this phenomena with very low success to be honest. For example, probable the main ...
1
vote
1answer
28 views

How can i use the same template file with a widget and category loop?

i wrote a widget and i want to use category template which is located in "themename"/template-parts/content.php". <?php // Category.php while ( have_posts() ) : the_post(); get_template_part( '...
3
votes
2answers
68 views

Is `query_posts` really slower than secondary query?

I know the main query is fast, since it gets data after parsing the URL and after WP_Query has been instantiated. We are in OO PHP. But is query_posts really slower than some secondary query that ...
0
votes
0answers
26 views

Exclude Featured Image Attachments from Wordpress Search Results

I'd like my search.php page to show all attachments except featured images (because they appear as duplicates of the posts that use them). I have seen some examples that do this for a query, but can'...
0
votes
1answer
32 views

Show one item per category of a custom post type

I'm having a custom type called portfolio with different categories. I want to display all my categories except one. I only want to show one item per category on my page. I'm been busting my butt on ...
0
votes
0answers
21 views

Display Posts in Admin Page

I create a admin page. Now I need to display posts in that page. Should I use WP_Query or get_posts()? (Pagination should be there) Note : I have read When should you use WP_Query vs query_posts() ...
0
votes
0answers
16 views

add date of most recent custom post type

I have a custom post type called products, it is categorized by a custom taxonomy called product_category. I'm trying to have a "last updated on" note on the taxonomy archive pages. I was hoping ...
0
votes
0answers
29 views

How to query post from sub-categories on category archive and display posts?

On a custom taxonomy archive from the taxonomy called 'books' (taxonomy-books.php) I want to list all subcategories that are assigned to the parent category. And then for each subcategory I want to ...
-1
votes
1answer
36 views

Show only posts from todays date [duplicate]

<?php if ( have_posts() ) : ?> <?php // Start the loop. while ( have_posts() ) : the_post(); get_template_part( 'content', get_post_format() ); // End the loop. endwhile; else : ...
1
vote
1answer
20 views

Wordpress Search Results for Multiple Post Types

I want to show both posts and attachments in the search results. Basically, I need something that says if the post has a thumbnail, show it. else show the attachment image (since they don't have ...
0
votes
1answer
12 views

Highlight specific user with custom field value

I'm working on a Wordpress project with some friends from school. But there's a problem with highlighting a user on the website. The idea is to create a 'User of the month' thing. In the user ...