Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1255895
    davidferp
    Participant

    Hello X-team,

    I am working to add these three elements (in this order) after the content of every blog post:

    1) Previous/Next buttons for blog post navigation
    2) Social sharing buttons
    3) A recent posts strip

    After making changes in my /x-child/functions.php (in the active child theme) I see I cannot horizontally align the thumbnails in the recent posts strip (see attached picture). Any way to force the alignment?

    Also, I would like to know if the functions.php is the right place fur these changes or I should place them somewhere else like in the /x-child/framework/views/global/_content-the-content.php?

    For your reference, my /x-child/functions.php looks like this:

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Add Recent posts after the single post content
    // =============================================================================
    function x_add_recent_posts ( $content ) {
      if ( is_singular('post') ) 
      {
        echo do_shortcode('[recent_posts count="3"]');
      }
    }
    add_action('x_before_the_content_end', 'x_add_recent_posts');
    
    // Add Social Sharing after the single post content
    // =============================================================================
    function x_add_social_sharing ( $content ) {
      if ( is_singular('post') ) 
      {
        echo do_shortcode('[share title="Share This Story" facebook="true" twitter="true" google_plus="true" linkedin="false" pinterest="true" reddit="false" email="true"]');
      }
    }
    add_action('x_before_the_content_end', 'x_add_social_sharing');
    
    // Add Previous/Next buttons in single post content
    // =============================================================================
    function add_next_post_item_link ( $content ) {
    	if ( is_singular('post') ) {
    		$prev_name = do_shortcode('[x_icon type="chevron-circle-left"]') . ' Previous Story';
    		$next_name = 'Next Story ' . do_shortcode('[x_icon type="chevron-circle-right"]');
    		$next_link = get_next_post() ? '<a style="float: left;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : '';
    		$prev_link = get_previous_post() ? '<a style="float: right;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : '';
    		$posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>';
    		return $content . $posts;
    	} 
    	else 
    	{
    		return $content;
    	}
    }
    add_action ('the_content', 'add_next_post_item_link' );

    Thanks a lot!

    #1255897
    davidferp
    Participant
    This reply has been marked as private.
    #1255961
    Christopher
    Moderator

    Hi there,

    Please add following code in Customize -> Custom -> Global CSS :

    .wp-post-navigation-next {
        display: inline-block;
        width: 100%;
    }

    You added your code in the right file.

    Hope that helps.

    #1256123
    davidferp
    Participant

    Thanks a lot Christopher, that code worked like a charm, as always.
    Perfect as always 🙂

    #1256164
    Christopher
    Moderator

    You’re welcome.

  • <script> jQuery(function($){ $("#no-reply-1255895 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>