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

Loop through all posts, show attachment if there

I've created two simple foreach loops: one for all posts, one for all attachments. I want it show every post title, and if there is an attachment, show that attachment. I have, thus far: ...
0
votes
1answer
33 views

Running the Loop outside of WordPress

I have a static website and WordPress installed at mywebsite.com/blog. I have a page on my external static website which displays a list of all posts [per the codex][1] using the following code ...
0
votes
1answer
40 views

Get the ID of the current post's child category

A client of mine wants to create a simple "related posts" loop that shows 6 of the most recent posts that match the current post's category. The issue is that every one of their posts have the same ...
0
votes
1answer
31 views

Does query_posts have an effect on get_the_category?

I am having trouble debugging a situation, and I think some better background information on how these systems work would be very helpful. I know that the use of the function query_posts is strongly ...
0
votes
1answer
20 views

filter a loop base on specific category

i am going to filter my loop base on the category the problem is that when i am using the following code it display all my post. // Query args $custom_cat_args = array( 'posts_per_page' => 15, ...
0
votes
1answer
46 views

problem with using serveral loop in wordpress theme

i am using several loops like this <?php $posts = get_posts('numberposts=1&order=DESC&orderby=post_date&category='.get_cat_ID( 'سیاست' )); foreach ($posts as $post) : ...
0
votes
1answer
42 views

how to use custom loop in the_content filter

Trying to use the the below code for my CPT 'state' like add_filter('the_content', 'my_custom_loop'); but the trial and error is not getting me anywhere. I can't use a single-{post_type}.php since i ...
0
votes
1answer
21 views

Can't print out returned value

Function to return the meta value as per author. <?php function ac_author_score() { $userID = get_the_author_meta( 'ID' ); $query = array ( 'author' => $userID, ...
0
votes
1answer
83 views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
1answer
37 views

posts_nav_link(); not showing up on static pages

I've got two different loops. The default on the homepage, but a secondary loop on the archive page. It grabs all the content, like so: <?php // WP_Query arguments $args = array ( ...
0
votes
1answer
80 views

Loop through posts by each term and exclude duplicate posts assigned to several terms

Okay, i'll try to go a bit more into detail. What i did with this code is getting a list of artists ordered by alphabet. In this list i'm showing all corresponding news posts to this artists term. ...
0
votes
1answer
49 views

Creating array to compare custom field values

I think I need some guidance here. I have a list of custom posts on a an archive template page that displays information from each of the custom posts. They are looped through using WPQuery: ...
0
votes
1answer
39 views

Need a conditional to test if title of parent page matches title of child page

In my main loop, I need to incorporate proper html markup into a conditional to test if title of parent page matches title of child page and do (or do not) display certain content. Default might be ...
0
votes
1answer
29 views

Show post if in category

I've searched a lot for options like has_category, in_category, get_the_category, but I couldn't make them work Here's my pastebin http://pastebin.com/Zi7auvtv I want this code to run only if the ...
0
votes
1answer
15 views

Loops in category description

I would like your help to find how to do a thing I need: I have some posts, for example: Article Title: Banana Article Title: Orange Article Title: Lemon Article Title: Strawberry All this ...
0
votes
1answer
35 views

Multiple Queries and Loops within CPT Archive

I have a Custom Post Type called 'properties', and have set up an Archive page to display posts within that category. Essentially, the Archive page needs to contain 3 different query types; the first ...
0
votes
1answer
26 views

How to display thumbnail if post is assigned one otherwise not

I would like to display the most recent post in a block, and if the post is assigned with a thumbnail I would like it to be shown on the left to the post content. This is my code that I have been ...
0
votes
1answer
74 views

the_content() “crashes” for single pages

I have big trouble with the_content() for single.php. Whats my problem? the_content() doesn't give any output on single pages furthermore it crashes (no other PHP code below the function call is ...
0
votes
1answer
24 views

Adding a category at even positions on main loop with modified pagination

I have different categories showing over main loop. I want to add a specific category post at even positions of main loop. Example current post list with categories: cat1 cat1 cat1 cat1 required: cat1 ...
0
votes
1answer
52 views

Compare Two Custom Post Types Using The Same Custom Taxonomy

I have two post types, courses and testimonials, sharing the same taxonomies. What I am looking to accomplish is to check whether a course is in the same category as a testimonial. Then display if it ...
0
votes
1answer
28 views

Query counting excluded category on paged loop

I have an Index.php with a basic loop with this query before: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'category_name' => 'work', ...
0
votes
1answer
27 views

Inserting A Feed and Sidebar into an HTML Page

I have a website I've built and the last step is to configure the blog page. My html and css is solid but my php and wordpress development knowledge is almost non-existent. I don't need a dynamic ...
0
votes
1answer
58 views

wp_query inside the_loop

I am having this issue with my loops. I am making a shortcode that will be called from the main query. It will display on the front page from the_loop. for some reason that I can't figure out. The ...
0
votes
1answer
45 views

Posts without featured image using other post's featured image

I am using the following code (see bottom) to display a custom post called 'artists'. I am also using <?php if (has_post_thumbnail( $post->ID ) ) so I can set the background of a div using the ...
0
votes
1answer
423 views

Conditional two level dropdown filter for custom post type

I have set up a custom post type and taxonomy. The post type is called Local Services and the hierarchical taxonomy is called Regions. The Regions have child categories called Areas. I have set up a ...
0
votes
1answer
57 views

WordPress nested loop not working

Why is this code not retrieving the posts of custom post type "graphic-design"? <?php $args = array( 'pagename' => 'graphic-design' ); $query = new WP_Query($args); while ( ...
0
votes
1answer
62 views

get_posts and wp_autop (remove filter)

I just transformed my query_posts function in a get_posts function. Here is my old function: <?php // The Query query_posts( 'cat=170&showposts=4' ); remove_filter('the_excerpt', 'wpautop'); ...
0
votes
1answer
30 views

Trouble preventing duplicate posts between 2 loops on homepage

I know this topic has been covered multiple times before, but I've tried every tutorial I've found online and haven't been able to figure it out. I'm using the free NewsMojo theme ...
0
votes
1answer
54 views

Best hook for a function which adds shortcodes to the system?

I have a plugin released, and one of my customers was reporting a problem where the plugin was outputting ads in the header area of their website. I have a function defined which contains my ...
0
votes
1answer
63 views

Second level subcategory

I'm trying to get anoter level subcategory to show in my select option. I've managed to get one... how can i get the other? <?php $taxonomies = array(CUSTOM_CAT_TYPE); $args = ...
0
votes
1answer
43 views

How can I put a custom field as the link of a button shortcode?

I have been working on a custom page template, and cannot seem to figure out how to have a custom field for URL's as the link for a button in the loop. Here is my code <?php echo ...
0
votes
1answer
48 views

How do I exclude posts by custom field value?

I need to exclude posts that have a custom field 'city' value of 'Melbourne'. After much searching I think the solution might consist of 2 parts. In functions.php : A function to get the post IDs ...
0
votes
1answer
79 views

How to different style first 3 post on Category Archives Page

I searches lot of time but every one said first post. I need first 3 post different style with title , content.
0
votes
1answer
44 views

Pagination on Custom Loop

I want to style the latest post differently than all the other posts in a category on a custom page. So far I have this code below which does exactly that: <?php if (have_posts()) : ?> ...
0
votes
1answer
19 views

Pagenav Not appearing on custom Template

I've just finished building a custom page template using the following code. The issue is the pagenav doesn't work - But works on every other page with multiple posts. I want this one to appear if ...
0
votes
1answer
61 views

wp_query pagination links producing 404

I've searched thousands of related posts and can't seem to get the pagination to work on this loop. As soon as i click next page i get a 404 //get the search term if (!empty($_GET["s"])){ $s = ...
0
votes
1answer
80 views

How to retrive Custom Post Type Meta Fields in Custom WP_Query

Can some one let me know How I can render the Custom Post Type Meta Fields (Meta-boxes). I have a Custom Post Type Called "News" and I successfully added a Metabox to my Custom Post Type called "News ...
0
votes
1answer
110 views

multiple values in an array for category__and does not work with WP_Query

So I'm looping with WP_Query and here is my code: $country_posts = new WP_Query(get_direct_children($continent_cats)); if ($country_posts->have_posts()) : while ($country_posts->have_posts()) ...
0
votes
1answer
40 views

Randomly placed sticky custom posts complemented by blog posts

On my index.php file I am showing the most recent posts using the standard index.php file. However, I'd like to include a custom post type (named products) in this standard loop. Have about 6 products ...
0
votes
1answer
52 views

Display Custom Taxonomy of custom post type

I am stuck on trying to create a template page that displays a list of the names in a specific custom taxonomy of a custom post type I created. The custom taxonomy is locations and clicking on a ...
0
votes
1answer
14 views

Variable not working in sidebar loop

I have variable working in the loop of my homepage, but when I try to use that line $variable = $post->post_title; $variable = str_replace( ' - ', '<br />' ,$variable); echo $variable; in ...
0
votes
1answer
88 views

What is the best way to get the first few post from WordPress in different divs using a loop?

I got the first post using the loop but I can't get the second post. I would like every post to be in a different div but the same style as the first post. To do this, I would probably need to ...
0
votes
1answer
74 views

Fake Single Wordpress Post (Page) Loop

In a plugin, I am building a custom page with add_action('template_redirect', function(){ include(TEMPLATEPATH."/page.php"); exit(); }); add_filter('the_title', function(){ return "Virtual ...
0
votes
1answer
22 views

Tags interfering with next_post_link();

I am creating a theme in WordPress. I am using query_posts('tag=front') to limit the posts on the front page. However, I want to let the user navigate through all posts, regardless of tags when on ...
0
votes
1answer
38 views

WordPress Multiple Loop: Home/Archives Page, with pagination

I can not write English, and I'm using the google translator. I believe that pictures can say more than words. Please watch this. http://i.stack.imgur.com/99YKW.jpg is possible to do something? ...
0
votes
1answer
193 views

offset WP_Query by negative 1

I have an event loop and I was wondering if it's possible to somehow offset the loop by -1 so the prev and next posts of the current post are shown. --edit-- Okay thanks for your comments, my ...
0
votes
1answer
54 views

Exceprt not displaying

I am using a custom template homepage in which I want to display some excerpt from a category but it's not displaying as I code for just the_excerpt. I have a confusion too, they say the the_excerpt ...
0
votes
1answer
37 views

Is there a way to target only images within the loop?

I'm new to WordPress and I'm trying to target specific parts of the content. I understand how to grab the title with get_title() — is there something similar for images?
0
votes
1answer
54 views

Placing the content of one post in two side by side columns, newspaper style

I'm trying to place two columns side by side like a newspaper does and display one post's content within both. I've been trying to explode the content at my h4/90 words and echo the rest of the ...
0
votes
1answer
259 views

How do we create a custom taxonomy template that loops through child categories in term order?

We're building a site that sells Biking Gear : http://www.nimblewearusa.com.php53-16.dfw1-2.websitetestlink.com/ We're using the Genesis Theme Framework, and developing a custom child theme. It has ...