WordPress.org

Ready to get started?Download WordPress

Forums

Ambrosite Next/Previous Post Link Plus
[resolved] Can't get it to work with the Roots theme (6 posts)

  1. Twansparant
    Member
    Posted 1 year ago #

    Hi there,

    First of all; great plugin! I have (succesfully) used this plugin before, but somehow I can't get it to work this time... I'm using the Roots Theme.

    In the base.php template I'm using the following code to navigate between event custom posts types, sorted by the custom meta field wpcf-event-date managed by the Types plugin.

    <div class="navigation">
    	<?php if( is_single() && get_post_type() == 'event' ) { ?>
    		<div class="prev event">
    			<?php if ( function_exists('previous_post_link_plus') ) {
    				previous_post_link_plus( array(
    					'order_by' 			=> 'custom',
    					'meta_key' 			=> 'wpcf-event-date',
    					'post_type' 		=> 'event',
    					'loop'				=> true,
    					'format' 			=> '%link',
    					'link' 				=> '<i class="icon-chevron-right icon-white"><</i>',
    					'tooltip' 			=> '%title'
    				));
    			} ?>
    		</div>
    		<div class="next event">
    			<?php if ( function_exists('next_post_link_plus') ) {
    				next_post_link_plus( array(
    					'order_by' 			=> 'custom',
    					'meta_key' 			=> 'wpcf-event-date',
    					'post_type' 		=> 'event',
    					'loop'				=> true,
    					'format' 			=> '%link',
    					'link' 				=> '<i class="icon-chevron-right icon-white">></i>',
    					'tooltip' 			=> '%title'
    				));
    			} ?>
    		</div>
    	<?php } ?>
    </div>

    The problem is nothing shows up...
    I have at least 2 'event' posts so it must return something right?

    I tried using 'order_by' => 'numeric' instead of 'order_by' => 'custom', I disabled all my other plugins, I even put my code in the single event template, but none of those solutions work... Any idea what I'm missing here?

    Thanks!

    http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/

  2. ambrosite
    Member
    Plugin Author

    Posted 1 year ago #

    The only obvious problem I see is that the post type must be enclosed in double quotes:

    'post_type' => ' "event" '

    Try that, or just remove the post_type parameter completely (95% of the time it is not needed; the plugin auto-detects custom post types in most cases).

  3. Twansparant
    Member
    Posted 1 year ago #

    Jup, that was it! Thanks a lot!
    Couldn't find that in the documentation though...
    Cheers!

  4. Twansparant
    Member
    Posted 1 year ago #

    Got another question (if you want to me to make a new thread let me know), but is it possible somehow to echo the position of the next & previous links in the created array.

    Let's say I have 4 'event' posts and I sort them using the 'meta_key' value, that results in a certain order of the posts [1,2,3,4]. If I'm in post '3' of those 4, could I echo the number '2' next to the previous link and the number '4' next to next link?

    Thanks again!

  5. ambrosite
    Member
    Plugin Author

    Posted 1 year ago #

    Check the documentation again, it is clearly stated in the paragraph explaining the post_type parameter:

    "The string must be formatted exactly as shown here, with each post type enclosed in double quotes, and separated by commas"

    To answer your second question, I am afraid that is not possible the way the plugin is currently written. The underlying SQL query would have to be changed in order to display that information.

  6. Twansparant
    Member
    Posted 1 year ago #

    Sorry my bad! Totally missed that...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic