Tagged Questions

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

-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', ...
-1
votes
0answers
17 views

Get posts by meta_key and meta_value [on hold]

For getting value by meta key and meta value. $args = array( 'meta_query' => array( array( 'key' => 'meta key here', 'value' => 'meta value here', ...
0
votes
3answers
32 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
15 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
30 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
48 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
27 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
35 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
18 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
38 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
27 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
79 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
29 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
30 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
24 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
79 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
23 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
90 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
49 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
92 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
87 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
63 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
29 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
32 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
60 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
53 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
48 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
28 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
224 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
65 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
40 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
40 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
104 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
56 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
56 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
402 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
51 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
40 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
71 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
52 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
60 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' ...
0
votes
0answers
27 views

Issue with recent custom post type permalink

I'm using the following code in my footer to get the latest posts from specific custom post type. <?php //WordPress loop for custom post type with taxonomy $my_query = new ...
0
votes
1answer
41 views

Wordpress plugin: Getting posts where checkbox selected

I would like to have a plugin where I could work with all post data from posts that have a selected checkbox.. To get all posts is simple with the get_posts( $args ); function... But how to add a ...
0
votes
1answer
102 views

Custom loop in addition to default on archive page

I'm trying to create an interface on the admin that will allow our authors to select top resources to place as an aside on our archive page. I'm trying to add a loop in addition to the original query ...
0
votes
2answers
157 views

Auto-change Post Status on First Page Load

I have created a number of custom post statuses using the EdiFlow plugin. Now, what I am trying to do is, if the contribter visits the post edit page and the post status is "assigned" to automatically ...
0
votes
1answer
123 views

get_posts works but new wp_query doesn't

I was told that get_posts is a very bad function to use that that making a new WP_query is absolutely better. My problem is that my get_posts code works but when I tried turning it into a WP_query, ...
0
votes
2answers
84 views

Retrieving 3 latest post from each of 5 different custom post types

I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query: $query = new WP_Query( array ( 'posts_per_page' => 15, ...