get_posts() is a function for creating multiple loops. It retrieves a list of latest posts or posts matching criteria.

learn more… | top users | synonyms

1
vote
1answer
21 views

Only showing the_date and the_excerpt for first entry in get_posts

this code below shows the titles and links for 5 posts in get_posts no problem but only displays the date and excerpt for first post... any help please? <?php $args = array( 'posts_per_page' ...
0
votes
2answers
30 views

Fetching All Posts (200+) in a Category - Performance Issues?

I want to get the IDs of the 2 previous and 2 next articles in a certain category to show them as a "related videos" playlist. I know that there are the functions previous_post_link and ...
0
votes
3answers
75 views

Paginate get related post by author function

Is it possible to get this function paged? I've tried to add previous and next links but i'ts not working... function get_related_author_posts() { global $authordata, $post; ...
0
votes
0answers
8 views

Display Children Category post and child post under it

Hi I need to display only child category post in home page and then its children title under it in home page recent posts . While doing this it displaying category children post too in home page ...
0
votes
2answers
34 views

Display all Post titles with Category and Tag

I am trying to display all posts that are in a specific category and have a specific tag. This is what I have so far but it seems to ignore the & and make it or. <?php $myposts = get_posts( ...
0
votes
1answer
25 views

Get x recent posts by author?

So I have ten authors on my site, and I want to designate a section where it shows the ten authors and their 5 latest posts in the form of the post title linking to the post. I tried using the ...
0
votes
0answers
14 views

Send POST variable with 'post_publish'

I have a custom button which triggers my page builder to load on the post.php page upon clicking it. However, I want to send a variable as well with it. Here's what I tried $('#post').attr('action', ...
0
votes
1answer
31 views

Get all posts with a certain meta key, except for one with specific title

I need to return all posts with post_test_safe == 1 and exclude one with title ="Special title" Some kind of combined meta query but haven't got anything to work. function getAllPostIdsTest(){ ...
0
votes
1answer
25 views

Worpress url parse

I want to display posts in certain category only with given tag. Problem with parsing url slugs. For example, I have category named 'Clothes': example.com/clothes/ I can get posts in this category ...
1
vote
3answers
72 views

WP Query post meta value

I'm trying to get posts which have applied the meta value trainees. $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', ...
0
votes
2answers
55 views

Get posts by category name

I'm having a terrible time trying to figure this out. I've registered a custom taxonomy (clinical-programs) and like to list all the PAGES that are assigned to particular page(s).
0
votes
1answer
86 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
1
vote
1answer
52 views

WP_Query post_parent parameter always returns children of current page

Well the title gives it all away... Here's the code: $args = array( "post_type" => "page", "post_parent" => $cat, // runs through a loop of 5, 128, 130 "posts_per_page" => -1 ); ...
0
votes
3answers
48 views

Re-sort get_posts query results

I have a query that pulls fields from the 3 most recent posts for a carousel: get_posts('posts_per_page=3') I need to re-order the results so that instead of it being 1, 2, 3 it is 3, ...
0
votes
1answer
41 views

XMLRPC - getPosts - How to call from remote site?

For the purpose of this question, I have two WordPress websites. Let's call them "Portfolio" and "News". Portfolio is a "pages" only website while "News" is a "posts" only website. On the Portfolio ...
-1
votes
2answers
45 views

Latest post on specific category and custom css

I'm trying to create a new home page with two columns for latest post of specific category. This the page code: <div id="left-column"> <div class="bloccorosso">News & ...
0
votes
2answers
60 views

get_posts query matches too many results

I have a query inside a function that is returning matches that i don't want, for example when the $id=116 it is also returning results where the meta_key 'funds_id' is 11687. public function ...
1
vote
2answers
45 views

Get posts under custom taxonomy

I am not getting the posts under custom taxonomy(fabric_building_types).I am getting cat_id and cat->name also but not able to get the posts. $args = array( 'type' => ...
1
vote
1answer
27 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
2answers
56 views

Reworking function for counting custom post type posts count

I am trying to rebuild my inline posts counting to a function. What would be the best way to do that? Here is my inline code: $posts = ...
0
votes
0answers
20 views

Posts of Certain Category as Menu

I want to retrieve posts by certain category dynamically as a menu. What I need is: On the left-side of the page I want to display a menu as following | Category Name | | Post of This | | ...
1
vote
1answer
60 views

List all posts from past week grouped by sub-category

On a category specific template, I want to list all the posts from the last 7 seven days for that single single category and group them by subcategory. This is the code I have so far, which lists the ...
0
votes
1answer
35 views

Cache Get_posts

I have a query (see below) that gives a list of 10 news items ordered by the meta value "event_date" and filtered so that only posts earlier than today are displayed. This query is taking two seconds ...
0
votes
4answers
242 views

How to limit get_posts()?

I've been researching this for the last 3 days. I'm triyng to limit the maximum amount of posts retrieved by get_posts(). I have this chunk of code: // all filters should be applied here $args = ...
0
votes
1answer
42 views

get_posts() using an array of post ids [closed]

There's an array of post ids, and I'd like to use it to load these particular posts. I'm using get_posts() but there's some kind of problem using an array for 'post__in' argument. Here are the ...
0
votes
2answers
55 views

Get all pages and posts with get_pages() or get_posts()

Trying to get all posts (with all I mean all pages, posts and posts from custom post types). Is this possible? The documentation says I can only pass a string as post_type so how can I get all pages ...
0
votes
0answers
45 views

wp_list_pages show all pages in sitemap

I am trying to list the pages of my site but actually list them all. I can use wp_list_pages(); However I have a custom post type "services" with archive false. I also have a page named services ...
0
votes
1answer
125 views

Display content based on a users login

I was wondering if this is possible. I created a client portal where they can see all of their work that was assigned to them (this is all being displayed on the frontend). Once they login, they are ...
0
votes
0answers
28 views

Get Posts by tag from a custom taxonomy

I have a custom post type called product, which have two custom taxonomies named as product_tags & product_categories. In My Product Categories archive page, I am listing tags. My requirement ...
0
votes
0answers
104 views

How to implement AJAX pagination for get_posts (CPT)?

I need to implement AJAX pagination: « Previous 1 2 3 ... 70 Last » for a CPT get_posts() loop: // main images query // all filters should be applied here $args = array( ...
0
votes
1answer
73 views

Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?

I have this code to display 4 posts of type "testimonial" on the Home page: <?php $custom_posts = get_posts([ 'numberposts' => 4, 'post_type' => ...
0
votes
1answer
134 views

attachment.php & flexslider—linking thumbnail to specific image

I am nearly there but need the help of the community to bring me home! I am linking from a "gallery overview" page (thumbnail grid) to a single, full-size image page (attachment.php) containing a ...
0
votes
0answers
114 views

Custom query not working in plugin admin page

I'm not sure what I am doing wrong, but I cannot use get_post, get_posts or WP_Query in my plugin admin page. I can use get_user_meta, and get_userdata, so I'm a bit confused as to why I cannot use ...
1
vote
3answers
76 views

Can I set and show “important” post in my blog?

I have the following doubt related to the WordPress posts showed in the home page. I know that in the home page I can show the latest published posts. But can I also show (before the latest posts) a ...
0
votes
1answer
35 views

one get_posts to return a number of custom posts for each meta value

I have setup a custom post 'product' with a custom field cf_type. I wish to have one get_posts that will return 20 total products, 10 products with cf_type: fog and 10 with cf_type: gof. Is that ...
0
votes
2answers
34 views

How to get latest page (not post) of User and display the content

I've been trying to get the latest Page, not post, by author ID and display it on a page. The reason it has to be a page and not a post is that the user will only be posting one page and a whole ...
0
votes
1answer
66 views

How to create content automatically when a post is published?

Goal: Ability to automatically create content in WordPress posts/pages. Goal Details: When a post is created/published, it will automatically create or configure content based on the base data inputs ...
0
votes
0answers
63 views

How to use get_categories results called in header.php on the homepage as well without calling the database twice?

I have a Wordpress blog with multiple categories and I have to display the last two posts of certain categories(not all of them) in the header. This is so as to have this information available ...
0
votes
2answers
56 views

Sort order in get_posts [closed]

I've created a custom template for a client. This is going to be a multilingual site setup on a Multisite install. As you can see under each category letter, the posts start out in alphabetical order ...
0
votes
1answer
29 views

Help to cleanup this code

I am trying to change my attachment page link yo example.com/photos/attachment_ID/post_name/attachment_name can you tell me how to call the parent post name function wpd_attachment_link( ...
0
votes
0answers
31 views

how to get wordpress categories list with thumbnails?

i am trying to get thumbnails list with their thumbnails images .i tried code below but it only gives categories list . i know there a could do using feed_image but i can't figure out how to do it ...
0
votes
1answer
265 views

Change attachment inside the_content using filters

I am in search of a snippet or function that will filter the embedded images inside a post to a custom size I have defined in functions.php. Here is the scenario: A client uploads and add any ...
0
votes
1answer
134 views

get_posts() forcing ignore sticky posts on main loop

I have a custom query using get_posts() that besides ignoring sticky on its main query, ignores sticky posts on main loop. Reading around I've found that get_posts() have some trouble with sticky but ...
0
votes
1answer
50 views

Exclude parent category when getting category posts by slug

I have the following category layout: Resources -- Documents I want to list the posts in the documents category, and have the following code: $args = array( 'posts_per_page' => ...
0
votes
1answer
56 views

what is the maximum number of post a wordpress loop can work with?

what is the maximum number of post a wordpress loop can work with? how many post can i display with 'posts_per_page' => -1? ive got 50,000+ pages and I want to sort through them, but I just get ...
-1
votes
1answer
167 views

Display post's description and caption

I am trying to get and display 5 featured posts. To achieve this target I have an offset of 5 recent posts. I have successfully fetched the posts' id's and images, but I failed to get every post's ...
0
votes
1answer
28 views

the paged param is allways 0

I am listing a custom post_type called ad using get_posts wich works fine, Problem that I have is that I am not able to read the paged param, wich I need in order to enable pagination, The thing is ...
0
votes
0answers
71 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
2answers
62 views

show posts in different styling

I would like to show categories in the front page with different behavior: categories to show posts in two styles [Three posts having the same style and then another two with the same style] ...
3
votes
2answers
824 views

How do you get posts by meta_query using the JSON API plugin?

I would like to get post with an API method using a kind of meta query. I have 2 custom fields "place" and "dayoweek" and I want to retrieve via API call all the post that have some values for this 2 ...