Trying to get a custom admin link working for a custom post type. I've managed to add a link to show all "sticky" posts next to the usual "All", "Published", "Trash", etc., but the actual query isn't working as I'd like it to.
In pre_get_posts, I'm trying to modify the query to do the following: - show only sticky posts - respect posts_per_page and pagination settings
If I try this:
$query->set('post__in', get_option('sticky_posts'));
$query->set('posts_per_page', 5);
...I see all sticky posts, but no pagination. Does having "posts__in" set mean the posts_per_page is disregarded?
Thanks for the info. Ditched "posts_per_page" but it didn't make a difference. My debug bar shows:
SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (2382,2358,2334,2331,2301,2298,2280,2262,2220,2226,2193,2157,2163,2136,2130,2109,2100,2084,2072,2026,2020,1961,1934,1846,1834,1756,1738,1709,1688,1552,1543,1498,1488,1482,1476,1438,1432,1412,1406,1400,1394,1391,1388,1358,1340,1319,1285,1282,1269,1227,1212,2621,2674,2659,3300,3313,3414,3560,3314) AND wp_posts.post_type = 'ad_listing' AND (wp_posts.post_status = 'publish') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC
posts_per_page
completely. And yes, add the query string.