get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.
0
votes
1answer
77 views
Add ul to its children with get_posts
I want to add a ul to the list when a page have a child, Im making a foreach on all the post_types so i don't think that i can use something like wp_list_pages. I have been trying to sort this out but ...
0
votes
1answer
104 views
Efficiently loop over huge number of posts
I want to loop all posts to do some processing, but one of my concern is there are many posts and it might used up my memory, so I want to loop posts with offset, something like paging.
e.g.
$posts ...
0
votes
1answer
55 views
Showing posts from 2 categories only on category.php
got myself in a bit of a pickle.
I want to display posts on category.php from the categories 'latest news' and 'custom models' only. The other category, 'press releases' is shown in a separate column.
...
0
votes
1answer
69 views
Get random custom posts from a custom post type
I created a custom post type named predic, I’m trying to get within one of this post other four random posts from the same custom post type. I used this code, but I keep getting the same post I’m in 4 ...
0
votes
1answer
64 views
populate array with posts
I want to generate an array of custom post types to add it to a options array.
I'm doing this to show a checkbox group populated with custom post type.
I have this array:
'options' => array (
...
0
votes
2answers
133 views
How to query for a page, get data, then query for child pages of that page
Basically, I want to query PARENT for a bunch of custom field data and echo it out. Then, I want to query all of the CHILD pages of that parent and echo out more data.
What's the best way to do it?
...
0
votes
0answers
62 views
Get_Posts() isn't returning the correct amount [closed]
I am using getPosts to retrieve a list of posts in a certain category. However, if I set a category the function only returns 6 posts. However, if I use the function without setting a category, it ...
3
votes
2answers
246 views
the_title() and the_permalink() won't work on AJAX calls
I've run into a strange problem.
I have a custom loop built with get_posts that works fine when loading the page normally:
<?php
$rows = get_posts(array(
'post_type' => ...
0
votes
0answers
13 views
Display the most recent post from multiple categories [duplicate]
Possible Duplicate:
Display only the latest post from multiple categories
I have been searching and attempting solutions for over a week with no success. I'm trying to display post ...
0
votes
1answer
159 views
Get posts from current category?
How can i display 5 posts from current category (exclude current post). Order by post time.
Example:
To day news to reading 3 (12/11/2012 - 8:10 PM)
To day news to reading 2 (12/11/2012 - 6:07 AM)
...
0
votes
1answer
246 views
Show last post from multiple categories using wp_list_categories
I have the following code that lists out the children categories on a separate page when you click on its parent category. The code renders a list like so:
Home › Archive for IQ Issue 7
Journal
...
1
vote
1answer
1k views
get all posts ID from a category
Problem: I need to get an array of ID's of posts from a given category If the category have any posts. This is to be used on a plugin options page.
So far I have:
$posts = ...
0
votes
2answers
100 views
How to Make infinite loop of post
I am using Post contents as a slider contents, i need to make the post infinite number of loop, ie, If i view the last post after that first post should display and before first post the last post.
...
0
votes
1answer
211 views
Help with WP_Query - Too many mySQL queries
I need some kind of help with wp_query. Am I doing something wrong? I am getting a lot of mySQL queries, while building a new theme.
My WP_Query is:
<?php
$args = array(
'post_type' => ...
1
vote
1answer
65 views
How to optimize my query filtering out unwanted data?
I use get_posts ($arg); to query the post table. Usually I need only three fields: post_title, ID and post_excerpt. But the data returned are many more, including post_content that is usually huge.
I ...
0
votes
1answer
395 views
get_posts by id not working
I have the following code:
global $post;
$current_post = $post->ID;
$array=range(1,$current_post);
$posts = get_posts('numberposts=5&post__in=' . $array . '&category='. ...
0
votes
1answer
166 views
get_posts() and global variables
I was reading this post: When should you use WP_Query vs query_posts() vs get_posts()?, which seems to have become the go-to post for understanding the difference between the different functions for ...
0
votes
1answer
376 views
Display post details by post ID
I need to display post details by ID on front page template (front-page.php).
On the front page I want to display the post’s title, excerpt & featured image. I have tried to do that but no idea ...
2
votes
2answers
198 views
Why can I not use setup_postdata($post) in the sidebar?
I have created a function that takes one parameter - post type, and will output each posts with some html and title, content etc within that. However, I want to be able to use functions associated ...
1
vote
2answers
80 views
Ordering posts by metadata
In my plugin, I use these instructions to obtain a list of posts:
$args = array(
'numberposts' => -1,
'offset' => 0,
'meta_query' => array(
array(
...
1
vote
1answer
347 views
Problem with get_posts, tax_query and counting the number of posts
I want to count the number of posts that has simoultaneously 3 different taxonomies. THe code i'm using is this:
$products = get_posts(array(
'post_type' => 'products',
'posts_per_page' ...
0
votes
1answer
69 views
Displaying posts on Homepage
I am wondering how to add a column to my homepage that shows the five most recent posts from the blog page located under the "Latest News" heading.
Here is the link to my development site.
...
1
vote
1answer
110 views
Logged in user ID as post ID
Is there a way to automatically insert the current user ID as the post category name or maybe have WordPress display only the post with a category name that matches the current logged user ID?
...
0
votes
1answer
167 views
Custom field to array?
I have a posts query that queries posts by ID but want to select those posts by enetering a custom field. Here is the query and where I want to put the custom field:
$query_args = ...
0
votes
1answer
106 views
Wordpress pagination URL posts not load
I set up wordpress newly and add next previous pagination in home page using following code
next_posts_link('Older Entries »', 0);
previous_posts_link('« Newer Entries', 0);
Pagination URL work ...
2
votes
1answer
161 views
get_posts inside cron
Edited to rewrite my question
I'll try to be as clear as possible, as I need to get this resolved quickly.
I disabled WordPress' cron, and added a real cron job on my server to call wp-cron.php ...
1
vote
1answer
112 views
WP_Query() and get_posts() can't handle over a thousand posts?
So I have a search function that just fetch custom posts and return them as a list.
function search() {
// post query args
$args = array(
'post_type' => 'post_type',
...
0
votes
1answer
184 views
Meta query: get posts with value in a multidimensional array
I have a custom post type, Album, which has a custom field called 'tracklist'. Tracklist is a multidimensional array which contains a track title and track link, like so:
$tracklist = array(
[0] ...
1
vote
1answer
186 views
Setting pagination for images attached to a post
I am trying to figure out how to paginate a post for it's images. I have a custom post type set up to act like a gallery - images only. And would like to paginate the images. I am having a hard time ...
0
votes
1answer
231 views
get_posts not finding argument: post_name
I am digging up posts with a specific slug:
Where
$postSlug = 'abc'
$args = array(
'post_name' => $postSlug,
'post_type' => 'post',
'post_status' => 'publish'
...
0
votes
1answer
31 views
How do I display the index position of a post from a custom post type?
So I have a custom post type (ex. songs) and have a few posts that I created for this post type.
I want to display them on a webpage in order (ex. 1, 2, 3, ...). How do I get the index position and ...
1
vote
1answer
67 views
How to get_posts having post thumbnail?
I have following code:
$posts = get_posts(array(
"meta_key" => "special",
"meta_value" => "surprise",
// "has_post_thumbnail" => true, // how to do that?
));
What should I do to ...
1
vote
1answer
319 views
How do I pass a post ID to the page URL?
I am using a form (gravity form) on my site. The form is inserted in a page (called form_page) on the users dashboard when they are logged in
http://example.com/dashboard/form_page
I am using a ...
0
votes
2answers
257 views
How to get single post by one author?
I just want to get the most latest posts by an author. I am using get_posts at the moment but I notice it doesn't take an author argument, so how I can I specify my author?
$args = array( ...
0
votes
0answers
14 views
How to query for attachments limited to posts [duplicate]
Possible Duplicate:
get attachments for all posts of particular post type
I have a small widget I've created which displays the most recent images which have been added to the blog. I also ...
0
votes
1answer
120 views
get_posts() seemingly ignoring post_type
I am trying to grab posts of post type "leads" (see below for the code I am using) however the query produced (obtained via debug queries) is including the clause 'where post_type in ("leads", ...
0
votes
2answers
154 views
get_posts cannot grab from specific category
I'm using get_posts to grab list of posts from custom post_type. I also want list to be limited to specific category. So I tried:
$postslist = ...
2
votes
1answer
272 views
Is it necessary to reset the query after using get_posts()?
Is it necessary to reset the query after using get_posts() ?
I have been looking at this page and I don't see any reference to get_posts() ... I can't make it out for sure from this page either.
I ...
2
votes
1answer
708 views
WP_Query vs get_posts
I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
0
votes
1answer
84 views
Execute PHP function inside the admin area
I want to ask if there is a hook for executing php inside the admin area, my problem is I'm trying to do the get_posts wordpress function inside a popup frame using the thickbox jQuery plugin, using ...
0
votes
1answer
305 views
get excerpt without images
Is there any way to not get the images with get_the_excerpt()? I am using a my_recent_post() function to pull posts onto the home page and I don't need to have it pull the images within the posts, ...
1
vote
1answer
298 views
Getting a custom post type image using 'get_post_custom'
I am trying to echo the image src of an image I have uploaded for my custom post type outside of the while loop.
I have used the following:
$custom_fields = get_post_custom($_GET['id']);
I can ...
0
votes
1answer
68 views
Select objects from get_posts()
How can I select the first/last object from the list returned by get_posts()?
How can I select the preceding/following object relative to an arbitrary object in the object list returned by get_posts?
...
-1
votes
2answers
181 views
How do I make content editable on wordpress [closed]
I'm working on moving a current site to wordpress
Just started exploring wordpress, I've created a child theme with my css, and added appropriate html structure index.php.
1 - Is this fine? Or do I ...
2
votes
3answers
448 views
Post count per (day/month/year) since blog began
I'm looking to echo the number of posts per month since the blog began, and for months where there was no posts echo '0'.
This is the output I want:
January 1, February 3, March 8, April 3, ...
...
0
votes
1answer
221 views
How to reset post data properly
I have this piece of code that I am calling within the loop to get image metadata ( title/caption and description ). It works fine but it only works for the first post in the loop. So I assume it ...
1
vote
2answers
81 views
How do you Query posts with nothing in common?
We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc)
How do you query multiple posts in a public query, ...
1
vote
1answer
252 views
Show recent posts from one category on a non-WP site
I'm trying to move back to WP for our blog, after struggling with a clunky CMS for a few years, but we'll be sticking with that CMS for the rest of the site. Is there a plugin (or code) that I can use ...
0
votes
2answers
246 views
Divide the list into two columns (get_posts)
The function below lists posts based on custom field.
The result is involved in a list <li></li>. What I would like to do is count how many list items there are, then divide it into two ...
0
votes
1answer
121 views
not empty categories don't show in menu [closed]
I'm trying to resolve a problem i have showing category posts.
I have added a category to my main menu, eventhough it has posts - in the basic theme it doesn't show, in my theme - it shows as a link ...