I really need some help, I dont know where else to turn with this request. I’d like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since I dont want post navigation on each post page and I want to control where it displays. In a DIV in an HTML structure I’ve created in a post.

So what I need is to generate shortcodes from get_next_post() and get_previous_post()

2 s
2

this is very simple to do…

 // next   
function next_shortcode($atts) {
        // global $post; -unnecessary 

           return '<div class="nav-next">'.next_post_link( '%link', '%title <span class="meta-nav">' . _x( '', 'Next post link', ' ' ) . '</span>',true ).'</div>';              
        }
        add_shortcode( 'next', 'next_shortcode' );

//prev
 function prev_shortcode($atts) {
     //global $post; -unnecessary 

       return '<div class="nav-previous">'.next_post_link( '%link', '%title <span class="meta-nav">' . _x( '', 'Previous post link', ' ' ) . '</span>',true ).'</div>';              
    }
    add_shortcode( 'prev', 'prev_shortcode' );

Goodluck!
Here for any question….

Leave a Reply

Your email address will not be published. Required fields are marked *