Pagination in a Shortcode. Get_next_posts_link not working but get_previous_posts_link works fine right next to it

This is an old question, but I needed the answer to this one as well. Here is the solution taken right from the WP codex… $prev = ‘<div class=”nav-previous”>’ . get_next_posts_link( __( ‘<span class=”meta-nav”>&larr;</span> Previous’ ), $loop->max_num_pages ); You need to append the max_num_pages parameter from the query to your output and it should work … Read more

Custom-post-type-archive: posts sorted/filtered by year?

create a variable to hold the $current_year you’re outputting, and check it against each event’s year, resetting the value when you encounter an event with a different year: $current_year=””; while ( $loop->have_posts() ) : $loop->the_post(); // this is just a simple example of the logic, // you’ll need to extract the year from your date … Read more

Add text to wordpress admin ‘Add Post’ edit

It’s not that hard, you can use the all_admin_notices-hook, which appears beneath the Post Updated/Saved, etc. messages box. Wrapped up in a plugin: <?php ! defined( ‘ABSPATH’ ) AND exit; /** Plugin Name: (#64933) »kaiser« Add post/page note */ function wpse64933_add_posttype_note() { global $post, $pagenow; // Abort in certain conditions, based on the global $pagenow … Read more

Custom Post Type Pagination & duplicate posts

I think the best way to implement this is to use pre_get_posts hook. Take a look at this code function customize_query( $query ) { $post = get_posts(array( ‘post_type’ => ‘projects’, ‘taxonomy’ => ‘featured’, ‘numberposts’ => 1 )); if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_type’, ‘projects’ ); $query->set( ‘posts_per_page’, 6 ); if($post && !empty($post)) … Read more

Having a 2nd admin page for a custom post type

Yes, that is absolutely possible. Have a look at the add_menu_page() function and use it like so: add_menu_page( ‘My 2nd CPT Menu’, // page title ‘My 2nd CPT Menu’, // menu title ‘edit_post’ // required cap, same as in register_post_type() ‘edit.php?post_type=yourCPT’, // edit.php + query string as slug <– this is essential ”, // empty … Read more