Help please with adding nav buttons and global block to the end of a post!

Hi, I’m using a plugin for team profiles on a site I’m working on and as far as I know, it just utilises the posts to do this. On a blog I’m able to add nav links to the end of a post using some CSS and script in the functions.php file. I’ve tried to adapt it to work on the profile page, but I’m not too sure what I need to do to get the nav to appear! Here’s the script I’m using - I haven’t put the full URL in, as it’s being built on a temp link, so I’ll put that in a secure note:

function x_add_post_navigation() {
		if ( is_singular('post') ) {
  			echo '<div class="navigation-post"><a href=“urlhere/meet-our-agents/">< Back to main page</a>';
			x_entry_navigation();
			echo '</div>';
		}
}

Also, I’d like to add a global block to the end of the team posts too, can you let me know how I can do this please.

Thanks!

Hi @core365,

It seems that the condition in your code is only for the Single Post whereas the given URL is a single post of Team Manager post type. You need to change the code is_singular( 'post' ) to is_singular( 'team_manager' ). Please find the following code with the modified condition.

function x_add_post_navigation() 
{
	if ( is_singular( 'team_manager' ) ) 
    {
		echo '<div class="navigation-post"><a href=“urlhere/meet-our-agents/">< Back to main page</a>';
		x_entry_navigation();
		echo '</div>';
	}
}

Hope it helps.
Thanks

Hi @tristup,

Thanks for the modified code, however it isn’t working I’m afraid! I’d be grateful if you were able to take a look and let me know if you can see what I’m doing wrong!

For the URL, I’ve tried ‘domainname/meet-our-agents/’ and also ‘domainname/team-details/’ but neither works.

Also, I’d like to add a global block to the end of the team posts too, can you let me know how I can do this please.

I’d be grateful of any help, thanks!

Hello @core365,

You have defined your x_add_post_navigation() function. You also need to declare it so that it can be displayed on the site. Perhaps this documentation can help you understand how you can create and declare the actions.

Note: We are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One or Care service for further assistance.

Best Regards.

Hi @ruenel,

I’d already added in the declare action, I had it in their to start with, but it’s still not working!

Also, I’d like to add a global block to the end of the team posts too, can you let me know how I can do this please - this is the third time I’ve asked this, can you tell me why this is being ignored please or am I asking something unreasonable?

function x_add_post_navigation() 
{
	if ( is_singular( 'team_manager' ) ) 
    {
		echo '<div class="navigation-post"><a href=“urlhere/meet-our-agents/">< Back to main page</a>';
		x_entry_navigation();
		echo '</div>';
	}
}
add_action('x_before_the_content_end', 'x_add_post_navigation');

Thanks!

Hello @core365,

The code is valid and correct. It is not displaying because the Team Manager post has its own post template. You will have to hook it to the post template instead. You may need to custom the template in your Child theme. We would love to investigate more and look into this. To better assist you with your issue, kindly provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

Hi @ruenel,

That would be great if you wouldn’t mind looking into it for me, thanks!

I’ll put the info in a secure note.

Thanks!

Hi @core365,

For some reason when I am in the middle of testing your website, I got an IP restriction.

Upon my initials findings, there are no hooks in the plugins to add the function after the single content and it will also require some knowledge of customization to display the content while customizing the files in the child theme. Regretfully, this option is outside the scope of your theme support. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

On the other hand, there’s a workaround. I suggest that you customize your team single page using the ACF and Layout Builder. You can easily add everything without customizing any PHP files. This option will require a lot of time but the good thing about it is you will familiarize yourself with the Layout Builder + ACF using Pro.

Layout Builder:

ACF:

Hope that helps.

Thank you.

Hi @marc_a,

That’s strange the firewall blocked you, I have no idea why it did that, sorry!

Many thanks for taking a look to see why it wasn’t working, and I always wondered what the Layout Builder was there for, but never had the time to look at it properly, so I appreciate the links you supplied, they’ll come in handy!

Does it mean I won’t be able to add a global block to the bottom of the team posts too without creating the page with the Layout Builder?

Thank you and I appreciate the time you’ve taken to look into all this for me!

Hi @core365,

I have added the following code into your child theme and found it is working. I just changed the action hooks to the_content.

function theme_slug_filter_the_content( $content ) {
    
    if ( is_singular( 'team_manager' ) ) 
    {
        $custom_content = '<div class="navigation-post"><a href="http://www.hrestateagents.b-w-hosting.co.uk/team-details/">< Back to main page</a>';
        ob_start();
        x_entry_navigation();
        $custom_content.=ob_get_clean();
        $custom_content.='</div>';
        $custom_content=$content.$custom_content;
        return $custom_content;
    }
    return $content;
}
add_filter( 'the_content', 'theme_slug_filter_the_content' );

Please remember that the above code will work if copied as it is and don’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes, which means we can’t fix it if it conflicts with something on your site nor will we enhance it.

Thanks

Hi @tristup,

Excellent! Thank you so much, I really appreciate that!

Would you be able to tell me how I add a global block to the end of the team member pages too please!

Thank you again!

Hi @core365,

Glad that we are able to help you. You can use the do_shortcode method to parse the Global Block as a shortcode. The example code is given below.

do_shortcode('[GLOBAL BLOCK SHORTCODE]');

Global-Blocks-Pro

hope this helps too.
Thanks

Hi @tristup,

  1. I’ve just noticed that the nav buttons have been added to the bottom of all pages, instead of just on the single ‘Meet Our Agents’ pages! Do you know what I’ve done wrong?!! I can’t see what needs to be changed to stop it from appearing on every page.

  2. Thanks for the code, I’ve added it into the function.php file, but nothing is showing on the single ‘Meet Our Agents’ page! I’d like the global block to show above the footer, just on the single Agents pages - I’ll put the URL in a secure note as an example of one of them.
    Here’s the code I’ve used, I’d be very grateful of any help!

     add_action( 'x_after_the_content_end', 'add_post_shortcode' );
     function add_post_shortcode() {
     	if ( is_singular( 'team_manager' ) ) {
     		echo do_shortcode( '[cs_gb id=253]' );
     	}
     }
    

Many thanks!

Hi @core365,

I have checked all the pages but find the buttons coming up, I went ahead and found that your previous code is the reason behind this, and I comment out the hook that resolves your issue.

And secondly, I would suggest you to use the the_content hooks instead of x_after_the_content_end and also remove the clause is_singular( 'team_manager' ) to get that in Archive page.

Hope it helps.
Thanks

Hi @tristup,

  1. Excellent! Many thanks for sorting that, I really appreciate it!

  2. Sorry, but I’m not quite following what you mean by using the_content hooks instead and to remove the clause is_singular( 'team_manager' ). Would you mind letting me know what I need to do to the following to get it to work to show the global block above the footer, just on the single Agents pages please!

     add_action( 'x_after_the_content_end', 'add_post_shortcode' );
     function add_post_shortcode() {
     	if ( is_singular( 'team_manager' ) ) {
     		echo do_shortcode( '[cs_gb id=253]' );
     	}
     }
    

Thanks!

Hello @core365,

All the hooks that you use will not work because those hooks are only present with the theme’s default post template. For Team Manager custom post type, it is using the WP Team Manager plugin’s single-team_manager.php template. This file does not have any hooks. This is the code of the single-team_manager.php custom post type template ( /wp-content/plugins/wp-team-manager/public/templates/single-team_manager.php):

<?php
/**
 * The template for displaying team single post
 *
 */

get_header(); ?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

      <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<?php
    if ( have_posts() ) :

    $settings = get_option('wtm_settings');

		// Start the loop.
		while ( have_posts() ) : the_post();

        $post_id = get_the_ID();

  			$social_type = $settings['social_type'];

			  $social_font_size = $settings['social_font_size'];
        // get social settings
        $social_size =$settings['social_image_size'];
        // get link new window settings
        $tm_link_new_window = $settings['link_new_window'];

        $tm_custom_template = $settings['custom_template'];

        //If there is no tm_social_size then load default
        if (!$social_size) {
          $social_size=16;
        }

        if($tm_link_new_window=='True'){
        
          $link_window = 'target="_blank"';
        
        }else{
          
          $link_window = '';
          
        }

        $job_title = get_post_meta($post_id,'tm_jtitle',true);
        $telephone = get_post_meta($post_id,'tm_telephone',true);
        $location = get_post_meta($post_id,'tm_location',true);
        $web_url = get_post_meta($post_id,'tm_web_url',true);
        $vcard = get_post_meta($post_id,'tm_vcard',true);
        $facebook = get_post_meta($post_id,'tm_flink',true);
        $twitter = get_post_meta($post_id,'tm_tlink',true);
        $linkedIn = get_post_meta($post_id,'tm_llink',true);
        $googleplus = get_post_meta($post_id,'tm_gplink',true);
        $dribbble = get_post_meta($post_id,'tm_dribbble',true);
        $youtube = get_post_meta($post_id,'tm_ylink',true);
        $vimeo = get_post_meta($post_id,'tm_vlink',true);
        $instagram = get_post_meta($post_id,'tm_instagram',true);
        $emailid = get_post_meta($post_id,'tm_emailid',true);
          

        $sociallinks = '<ul class="team-member-socials '.esc_attr($social_type).' size-'.$social_size.'">';
        if (!empty($facebook)) {
          $sociallinks .= '<li><a class="facebook-'.$social_size.'" href="' . $facebook. '" '.$link_window.' title="Facebook"><i class="fa fa-facebook-square" aria-hidden="true"></i></a></li>';
        }
        if (!empty($twitter)) {
          $sociallinks .= '<li><a class="twitter-'.$social_size.'" href="' . $twitter. '" '.$link_window.' title="Twitter"><i class="fa fa-twitter-square" aria-hidden="true"></i></a></li>';
        }
        if (!empty($linkedIn)) {
          $sociallinks .= '<li><a class="linkedIn-'.$social_size.'" href="' . $linkedIn. '" '.$link_window.' title="LinkedIn"><i class="fa fa-linkedin-square" aria-hidden="true"></i></a></li>';
        }
        if (!empty($googleplus)) {
          $sociallinks .= '<li><a class="googleplus-'.$social_size.'" href="' . $googleplus. '" '.$link_window.' title="Google Plus"><i class="fa fa-google-plus-square" aria-hidden="true"></i></a></li>';
        }
        if (!empty($instagram)) {
          $sociallinks .= '<li><a class="instagram-'.$social_size.'" href="' . $instagram. '" '.$link_window.' title="Instagram"><i class="fa fa-instagram" aria-hidden="true"></i></a></li>';
        }		        
        if (!empty($dribbble)) {
          $sociallinks .= '<li><a class="dribbble-'.$social_size.'" href="' . $dribbble. '" '.$link_window.' title="Dribbble"><i class="fa fa-dribbble" aria-hidden="true"></i></a></li>';
        }        
        if (!empty($youtube)) {
          $sociallinks .= '<li><a class="youtube-'.$social_size.'" href="' . $youtube. '" '.$link_window.' title="Youtube"><i class="fa fa-youtube-square" aria-hidden="true"></i></a></li>';
        }
        if (!empty($vimeo)) {
          $sociallinks .= '<li><a class="vimeo-'.$social_size.'" href="' . $vimeo. '" '.$link_window.' title="Vimeo"><i class="fa fa-vimeo-square" aria-hidden="true"></i></a></li>';
        }		        
        if (!empty($emailid)) {
          $sociallinks .= '<li><a class="emailid-'.$social_size.'" href="mailto:' . $emailid. '" title="Email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a></li>';
        }                                                        
        $sociallinks .= '</ul>';


        $otherinfo = '<ul class="team-member-other-info">';
        if (!empty($telephone)) {
          $otherinfo .= '<li><span> '.__('Tel:','wp-team-manager').' </span><a href="tel://'.$telephone.'">'.$telephone.'</a></li>';
        }
        if (!empty($location)) {
          $otherinfo .= '<li><span> '.__('Location:','wp-team-manager').' </span>'.$location.'</li>';
        }
        if (!empty($web_url)) {
          $otherinfo .= '<li><span> '.__('Website:','wp-team-manager').' </span><a href="'.$web_url.'" target="_blank">Link</a></li>';
        }
        if (!empty($vcard)) {
          $otherinfo .= '<li><span> '.__('Vcard:','wp-team-manager').' </span><a href="'.$vcard.'" >Download</a></li>';
        }                                               
        $otherinfo .= '</ul>';
        ?>


    <?php
    // check if the post has a Post Thumbnail assigned to it.
    if ( has_post_thumbnail() ) {
      the_post_thumbnail();
    } 
    ?>

    <header class="entry-header">
      <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    </header><!-- .entry-header -->

    <div class="entry-content">
      <?php echo $sociallinks; ?>
      <?php echo $otherinfo; ?>
      <?php the_content(); ?>
      <?php
        wp_link_pages( array(
          'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'wp-team-manager' ) . '</span>',
          'after'       => '</div>',
          'link_before' => '<span>',
          'link_after'  => '</span>',
          'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'wp-team-manager' ) . ' </span>%',
          'separator'   => '<span class="screen-reader-text">, </span>',
        ) );
      ?>
    </div><!-- .entry-content -->

      <?php edit_post_link( __( 'Edit', 'wp-team-manager' ), '<footer class="entry-footer"><span class="edit-link">', '</span></footer><!-- .entry-footer -->' ); ?>

      <?php // End the loop.
      endwhile;
    endif;
      ?>
     </article><!-- #post-## -->
		</main><!-- .site-main -->
	</div><!-- .content-area -->

<?php get_footer(); ?>

If we take a look at the code above, the line add_action( 'x_after_the_content_end', 'add_post_shortcode' ); will not work. It can only work if your use wp_footer hook. Therefore, your line should be updated into add_action( 'get_footer', 'add_post_shortcode' );

If you want to add the global block somewhere inside the “Content Area” or “Site Main”, it is best that you contact the creators of the WP Team Manager plugin for further assistance. They should be able to tell you how you can override or at least modify their single team manager template.

Hi @ruenel,

It’s worked, brilliant, thanks! Hooks are all a bit new to me and it’s something I’ll need to get to grips with more!

Many thanks for all your time and help, I really appreciate it!

Hello @core365,

Glad that we were able to help you. Please feel free to reach us if you have any query regarding our theme and theme settings.

Have a great day!
Thanks

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