Tagged: x
-
AuthorPosts
-
August 10, 2016 at 4:10 pm #1126195
bttrym8ParticipantI’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.
August 10, 2016 at 11:37 pm #1126728
FriechModeratorHi 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!
August 11, 2016 at 2:28 pm #1127615
bttrym8ParticipantWorked 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?!
August 11, 2016 at 7:46 pm #1128034
RadModeratorHi 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!
August 12, 2016 at 9:45 am #1128789
bttrym8ParticipantSolid 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?
August 12, 2016 at 1:55 pm #1129047
Nabeel AModeratorHi 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!
August 15, 2016 at 3:20 pm #1132434
bttrym8ParticipantWhen i replaced with that code, it worked, but made my facebook comments section disappear!
August 15, 2016 at 7:07 pm #1132661
JadeModeratorHi 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 credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
August 16, 2016 at 9:19 am #1133577
bttrym8ParticipantThis reply has been marked as private.August 16, 2016 at 12:05 pm #1133853
ThaiModeratorHi 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!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1126195 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
