Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1126195
    bttrym8
    Participant

    I’ve scoured the help forums and ran across a couple places where people had done something similar but not exactly what i need. Creating a new blog style site and want to automatically add three random posts to the bottom of each post, before the FB comments section. I know i edit the content-the-content.php to do it, but can’t get the code right. Everytime i enter the code from here https://community.theme.co/forums/topic/ethos-recent-posts-social-share/ it makes the FB comments section disappear.

    #1126728
    Friech
    Moderator

    Hi There,

    Thanks for writing in! Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Then add this on your child theme’s functions.php file.

    add_action( 'x_before_the_content_end', 'add_to_single_posts' );
    function add_to_single_posts() {
    if ( is_single() ) {
    echo do_shortcode( '[x_recent_posts type="post" count="3" offset="" category="" orientation="horizontal" no_sticky="true" no_image="false" fade="false"]' ); 
        }
    }

    Hope it helps, Cheers!

    #1127615
    bttrym8
    Participant

    Worked like a charm! Now just trying to set it up where they are all random posts instead of three most recents… I’m assuming it would be a code similar to the way the ethos featured image posts are selected?!

    #1128034
    Rad
    Moderator

    Hi there,

    How about utilizing Essential Grid plugin to display your random posts of most three recent? Then you can simply change the code with Essential Grid shortcode.

    add_action( 'x_before_the_content_end', 'add_to_single_posts' );
    function add_to_single_posts() {
    if ( is_single() ) {
    echo do_shortcode( '[replace_this_with_essential_grid_shortcode]' ); 
        }
    }
    

    Less coding and no need to re-invent existing feature 🙂

    Thanks!

    #1128789
    bttrym8
    Participant

    Solid idea i’m going to take a look into!

    How does one add a second shortcode into that? I.e. the social sharing shortcode as well?

    #1129047
    Nabeel A
    Moderator

    Hi again,

    You can replace the previous code with this one:

    add_action( 'x_before_the_content_end', 'add_to_single_posts' );
    function add_to_single_posts() {
    if ( is_single() ) {
    echo do_shortcode( '[replace_this_with_essential_grid_shortcode]' ); 
    echo do_shortcode( '[share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]' ); 
        }
    }

    Let us know how this goes!

    #1132434
    bttrym8
    Participant

    When i replaced with that code, it worked, but made my facebook comments section disappear!

    #1132661
    Jade
    Moderator

    Hi there,

    Would you mind providing us with login credentials 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

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1133577
    bttrym8
    Participant
    This reply has been marked as private.
    #1133853
    Thai
    Moderator

    Hi There,

    I added the following CSS under style.css and also added the share shortcode in the previous code.

    Everything looks good now:

    .fb_iframe_widget,
    .fb_iframe_widget span,
    .fb_iframe_widget iframe {
    	width: 100% !important;
    }

    Regards!

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