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

0
votes
0answers
11 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
26 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
20 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
35 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
34 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
42 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
40 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 ); ...
-4
votes
0answers
21 views

Get posts order by meta key and meta value [duplicate]

For getting posts order by meta key and its value use following code. $args = array( 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'moments_in_history', ...
0
votes
3answers
43 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
33 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
37 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
53 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
35 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
25 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
46 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
19 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
43 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
32 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
118 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
34 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
39 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
37 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
100 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
24 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
95 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
59 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
117 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
107 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
68 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
32 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
33 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
63 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
57 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
51 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
27 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
30 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
248 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
88 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
43 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
46 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
130 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
27 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
62 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
58 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
612 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 ...
0
votes
1answer
53 views

get_post_meta slowing down my page load (in a plugin)

I've been working on this project where I need to load events (custom post type) and a whole bunch of meta data for every event. The problem is that page loading times are getting longer and longer ...
0
votes
0answers
44 views

Any way for get_next_post() to use the actual post order instead of publish order?

I'm currently using get_next_post() and get_previous_post() to get their ID so that I can permalink my next/previous buttons for a custom post type. I'm also using a wordpress plugin called "Anything ...
0
votes
1answer
73 views

Secondary Query Is Breaking Main Query

I registered a Custom Post type called "quote" and I am trying to show a single random quote on every page of my Wordpress site. I'm pulling out a single quote with the following code: $args = ...
1
vote
1answer
59 views

Get posts from taxonomy URL

How can I get the posts from a custom taxonomy using the URL to determine which taxonomy term id is being shown? I tried to get posts via a category using get_category_by_path which returned false ...
-1
votes
1answer
64 views

show custom post's post in two different divs [duplicate]

I have created a custom post type. For that I have used this code add_action( 'init', 'broker_post_type' ); function broker_post_type() { register_post_type( 'new_broker', array( 'labels' ...