Inclusion of pagination to MEC posts

Hi there
I have 2 issues I cannot solve despite few hours of attempts. :weary: I have included pagination to posts using the function x_entry_navigation code found at the link below which is great but it is excluding posts/events created in Modern Event Calendar.

  1. How can this function include MEC single post pages, and;

  2. How can the next/previous arrows include the post title?

Thanks in advance.

Hello There,

Thanks for writing in!

1.) Where did you added the code? You are supposed to included it in x-child/framework/views/global/_content.php file. Could you please post the entire code of your modified template?

2.) And to include the post title next to the arrows, you need to update the code and use this:

function x_entry_navigation() {

	$stack = x_get_stack();

	if ( $stack == 'integrity' ) {
		$left_icon  = '<i class="x-icon-chevron-left" data-x-icon=""></i>';
		$right_icon = '<i class="x-icon-chevron-right" data-x-icon=""></i>';
	} else {
		$left_icon  = '<i class="x-icon-arrow-left" data-x-icon=""></i>';
		$right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>';
	}

	$is_ltr    = ! is_rtl();
	$prev_post = get_adjacent_post( true, '', false );
	$next_post = get_adjacent_post( true, '', true );
	$prev_icon = ( $is_ltr ) ? $left_icon : $right_icon;
	$next_icon = ( $is_ltr ) ? $right_icon : $left_icon;

	?>

	<div class="x-nav-articles">

		<?php if ( $prev_post ) : ?>
			<a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev">
				<?php echo $prev_icon; ?> <?php echo get_the_title( $prev_post->ID ); ?>
			</a>
		<?php endif; ?>

		<?php if ( $next_post ) : ?>
			<a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next">
				<?php echo get_the_title( $next_post->ID ); ?> <?php echo $next_icon; ?>
			</a>
		<?php endif; ?>

	</div>

	<?php

}

We would loved to know if this has work for you. Thank you.

Thanks for your reply and code. I found applying this code in the suggested path doesn’t work unless in the functions file (child) and it has no effect in the MEC pages in either paths.

I did have to add the sections (in bold below) to make it work as it was breaking the page (hanging spinner /white screen) with just that code.

It now includes the titles in Posts which is great but I still haven’t resolved the inclusion in MEC pages and while it is excluding unwanted categories it is only pulling content from its own category (generally a sub) when I need it to include the parent and subs. So in my case, I have various parents (News, Info, Recipes) and Cakes, Soups etc are subs (of Recipes). If it can pull all subs of the parent (eg Recipes) that would work better. Thanks in advance and very much appreciate the support. You guys rock at it!

add_action(‘x_before_view_global__comments-template’, ‘add_entry_navigation’ );

add_action( ‘x_after_the_content_end’, ‘x_print_navigation’, 999 );
function x_print_navigation(){
** if(is_singular( ‘post’ )){**
** x_entry_navigation();**
** }**
}
// Entry Navigation
// =============================================================================

if ( ! function_exists( ‘x_entry_navigation’ ) ) :
function x_entry_navigation() {

$stack = x_get_stack();

if ( $stack == ‘integrity’ ) {
$left_icon = ‘’;
$right_icon = ‘’;
} else {
$left_icon = ‘’;
$right_icon = ‘’;
}

$is_ltr = ! is_rtl();
$prev_post = get_adjacent_post( true, ‘’, false );
$next_post = get_adjacent_post( true, ‘’, true );
$prev_icon = ( $is_ltr ) ? $left_icon : $right_icon;
$next_icon = ( $is_ltr ) ? $right_icon : $left_icon;

?>

<?php if ( $prev_post ) : ?>
  <a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev">
    <?php echo $prev_icon; ?> <?php echo get_the_title( $prev_post->ID ); ?>
  </a>
<?php endif; ?>

<?php if ( $next_post ) : ?>
  <a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next">
    <?php echo get_the_title( $next_post->ID ); ?> <?php echo $next_icon; ?>
  </a>
<?php endif; ?>
<?php } **endif;** **// =**============================================================================

Hi @mediarevolution_nz,

It will only work on standard templates like posts. The MEC uses its own templates where hooks x_before_view_global__comments-template and x_after_the_content_end aren’t available.

The MEC only uses the same header and footer, so if you’ll use a hook located in the header then it should work. Like x_after_view_global__slider-below and x_before_colophon_begin.

Thanks!

Thanks for that but my knowledge of php scripts is fairly limited so can you be a bit more specific how this would be achieved. Also given this is a plugin that is provided with the theme, would it be worthwhile adding this script to the core files so it better integrates with the templates as they work well together otherwise. Thanks.

Hi There,

Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link to your site
  • WordPress Admin username / password
  • FTP credentials

Thanks.

Sorry i am still in local mode so if you can’t just send me the string of code to add then it will have to wait a while.

Hi @mediarevolution_nz,

According to your code, you have this

add_action( 'x_after_the_content_end', 'x_print_navigation', 999 );
function x_print_navigation(){

** if(is_singular( 'post' )){**
** x_entry_navigation();**
** }**

}

You just need to add or change the hook x_after_the_content_end to x_before_colophon_begin. Example,

add_action( 'x_before_colophon_begin', 'x_print_navigation', 999 );
function x_print_navigation(){

** if(is_singular( 'post' )){**
** x_entry_navigation();**
** }**

}

Since that hook is in footer which is present on MEC page, then it should work on MEC page too.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.