get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.
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 ...
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 ...
1
vote
1answer
518 views
latest 5 posts using switch_to_blog loop
im sure i must be doing something wrong and would really appreciate a little help.
I am trying to loop through all of my Sub Dir "Multisite" blogs using switch_to_blog, below:
global $wpdb, ...
1
vote
3answers
607 views
Only get_posts of certain post formats
I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats).
How would I implement has_post_format( 'standard' ), or something similar, into ...
1
vote
1answer
735 views
Get_Posts and multiple categories
I have created a custom query in hopes of showing the top posts from some child categories. It appears here: http://www.sitesofconscience.org/activities/whats-new
The query has a big flaw: some posts ...
1
vote
2answers
537 views
Only retrieve posts where post_excerpt has been filled out
I'm trying to use get_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts_where" filter on the query but my SQL is lacking. This is what I'm ...
1
vote
1answer
431 views
Automatically republish old posts
been seaching on google for a plugin for this and can't seem to find anything realiable. The only plugin I found is called "old post promoter". Any ideeas?
Can this be done with googl old fashion ...
1
vote
1answer
2k views
Sort “get_pages” by menu order not ordering
I'm using this bit of code to generate a page full of items but they won't sort into the menu order, any ideas as to why?
<?php $pages = get_pages(array('child_of', 'menu_order')); ?>
1
vote
1answer
42 views
Limit popular posts by days
I am using this get_posts array to retrieve top 15 popular posts by comments. The problem is that it shows those all those highly commented posts from the day posts were added into blog. So, the list ...
1
vote
1answer
126 views
WordPress get posts by date without query_posts
I'm want to get posts from the last 30days in a sidebar but I don't want to use query_posts, is there a way to achieve this with the get posts function?
1
vote
3answers
211 views
Check If posts exist in custom post type category, outside of loop
I'm building a navigation, outside of the main loop, that includes drop downs. I have a custom post type called 'Events', that has its own categories. I would like there to be a drop down if there ...
1
vote
1answer
141 views
How to get all children and grandchildren of a hierarchical custom post type?
I need to get all sub-posts of a specific (root) parent id.
get_posts( array( 'numberposts' => -1, 'post_status' => 'publish', 'post_type' => 'microsite', 'post_parent' => ...
1
vote
1answer
350 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' ...
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',
...
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 ...
1
vote
1answer
155 views
Get posts inside Get terms problem
i have a get_terms which loads correctly.
inside of it i have used get_posts. then using get posts i am
trying to get each post tags (and count <= not currently inside this script)
<?php
...
1
vote
2answers
85 views
Why is querying posts messing up my pages?
I am working on a theme at the moment and I have set up a post template.
This post template is linked to some custom post types.
When I query_posts for my post type on the actual post template ...
1
vote
1answer
236 views
How can I paginate a list of related posts?
My client's home page displays a paginated list of posts with thumbnails. Each list item, when clicked, navigates to a single post or page, and then uses a separate query to generate the same list of ...
1
vote
1answer
290 views
If meta key exists in get posts function otherwise create it
The following code fetches posts with the meta key home telephone numbers.
$metas = '';
$args = array(
'numberposts' => 1,
'post_type' => 'electors',
'orderby' => ...
1
vote
1answer
67 views
Sort posts by most recently modified
Is there a way to list posts in the order in which they were modified?
For example;
A user posts 5 posts (#1 being the oldest and #5 being the newest), by default they would be listed with #5 being ...
1
vote
1answer
526 views
How do I combine these 2 queries
I want to combine the 2 following queries so that ongoing promotions (query 1) shows before the rest of the promotions (query 2) but all together no more than 5 results show. Thanks.
Query #1 Ongoing ...
1
vote
1answer
200 views
Exclude images from “inserted into post” when trying to get attachments
I have here the coin-slider which takes all pictures from the gallery. I get the attachments through the following code:
$attachments = get_posts(array('post_type' => 'attachment', 'post_parent' ...
1
vote
1answer
3k views
How to show related posts by category
In my gallery site i want to show other pictures under the current picture (in single post). I seen more codes but it i asks to specify the category, but i dont want want specify the category manually ...
1
vote
1answer
158 views
Location-Based Pages displaying results near customer
I'm creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results ...
1
vote
1answer
786 views
how to exclude “featured” posts from the main loop?
In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts():
function ...
1
vote
2answers
623 views
Using get_posts with arguments found in meta keys
I am using get posts, but I need to refine the query based on posts where a certain meta_key has a certain value.
Something like this
<?php $reviews = ...
1
vote
1answer
4k views
Wordpress pagination with get_posts?
I need to make adjustments to a horribly written WP theme that (a custom theme that was written in tables, and bad code).
The theme has several custom templates, but pagination wasn't used and ...
1
vote
1answer
169 views
get_posts that haven't been assigned a specific custom field
I'm trying to use get_posts() to pull articles that have not been assigned a specific custom field. For example (not working):
$articles = get_posts(array(
'post_parent' => 0,
'post_type' ...
1
vote
2answers
600 views
Trying to only display 1 category using get_posts
I'm trying to only display posts from a certain category in a widget. I've tried it in a few different ways but it is still showing posts from all categories. Here's my code at the moment:
$posts = ...
1
vote
1answer
335 views
get post attachment using ajax
I'm developing a plugin and I'm trying to get the url's from a post's attachments with ajax.
If the user is on a single.php page. After some seconds, I'm sending an Ajax request, getting all the ...
1
vote
1answer
3k views
Get term SLUG by term ID
I have a hierarchical taxonomy called 'tarefa'
I have to display all posts from a child taxonomy. I used get_term_children function function to verify if the taxonomy parent has children.
If the ...
1
vote
1answer
75 views
Custom Loop, Match Category with Page: How to display post featured image?
I found this answer. It saved my day, but could you tell me how to display featured image of the post with the following code?
When I'm using
<?php echo $cpost->post_thumbnail('thumbnail', ...
1
vote
0answers
32 views
Query Problem in getting top viewed posts
I wanted to display top viewed posts by month, I add this code snip, to form a query and get required 15 posts, but it displays 3-4 posts.Here is my query:
global $post;
$args = array(
...
1
vote
1answer
211 views
query_posts() vs get_posts() multiple loops [duplicate]
I have a template which initially had one single loop and it was using query_posts, I added 2 more loops using the same method, However after reading allot about these it was concluded that I shall ...
1
vote
1answer
94 views
get_posts meta_value is serialized array, how can I grab specific posts with combination of meta_key/meta_value[0]->is_featured?
I've a postmeta key saved in DB: mediSHOP_product_extras
It's value is
Unserialized: Array ( [0] => Array ( [is_slider] => 0 [is_featured] => 0 [in_stock] => 0 [video_url] => ...
1
vote
1answer
133 views
Getting movie and serial on actor page
I'm building a cinema site, I came with a problem, let me explain:
Movies- are stored in Post's
Actors- are stored in Post Type - persoane ( taxonomy= lista)
Serials - are stored in Post Type - ...
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?
...
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 ...
1
vote
0answers
229 views
How to reload a select box of posts dynamically?
I'm using custom meta boxes for a project. I have created a custom taxonomy (select box) and I have another select box populated with Posts. I need to only load the posts based on the selection of the ...
1
vote
1answer
390 views
get_the_content(“more…”) returns full text
I'm creating shortcode [latest_post] and want to show post date, title and short content. (content has "more" separator). Here is code:
function shortcode_latest_post() {
global $post, $more;
...
1
vote
1answer
244 views
My post repeats itself on the second page [closed]
Hey the way i have my index coded is that it shows one full post and the rest of the post are excerpts, but when i click previous the 2nd page shows the same post from the first page, what can i do to ...
1
vote
2answers
368 views
Trouble using get_post
For Microkids related post plugin (http://www.microkid.net/wordpress/related-posts/)
He said "Using the get_post() function you could get any data you need from the related posts." and he posted this ...
1
vote
2answers
601 views
functions.php conditional tag only for custom post type
I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default ...
0
votes
2answers
262 views
How to query the latest 5 posts and sort them by title?
I'm looking to draw a menu listing of the latest "n" number posts, where the number "n" will be a user defined setting stored as an option.
n = 5; //Pull the latest 5 posts from the database.
The ...
0
votes
2answers
1k views
How Can i Get 5 Recent Post Title With Corresponding Link?
I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie ....
0
votes
2answers
880 views
Am I using get_posts wrong?
I have
<?php
$folioPosts = get_posts(array('category_name' => 'portfolio', 'numberposts' => 3));
if ($folioPosts->have_posts()) :
foreach ($folioPosts as $folioPost) :
...
0
votes
1answer
996 views
What's wrong with this post__not_in argument?
In the script below, the post__not_in argument does not appear to be working unless I hardcode the post ids inside the array(). Anything stand out?
If an item is in the category, but also in the ...
0
votes
2answers
414 views
Add filter to get_posts
So I am attempting to filter out certain posts in the get_posts call. Essentially, I want to be able to specify a certain block of posts, and only get the posts that correspond with the block. Right ...
0
votes
1answer
950 views
How to query custom post type by term?
This seems trivial but I can't get it to work. Here's my code:
$args = array(
'numberposts' => -1,
'eventcategory' => 'nice-events',
...
0
votes
1answer
165 views
Both a page loop and posts loop on the same page
I'm trying to get first the content of a single page (the one that is queried), and then in a small section below i want to display the title of my bloggposts as a "Latest News" section.
The problem ...

