Tagged: x
-
AuthorPosts
-
January 6, 2017 at 8:38 am #1318849
sandrayinParticipantHi,
How can I add a button (hyperlink to 1 url page) at the top and bottom of my content? I want to make sure the button is supported by WPML too. So far I have hardcoded it in the php using a child theme. Not a good idea.
Thanks!
January 6, 2017 at 12:48 pm #1319166
Nabeel AModeratorHi there,
Thanks for writing in! Please add the following code in your Child Theme’s functions.php file:
add_filter ('the_content', 'add_button_posts', 9999 ); function add_button_posts ( $content ) { $button = do_shortcode('<div style="text-align: right; margin: 5px 0;">[button type="flat" shape="pill" size="regular" href="#example" title="Example"][icon type="truck"]Pill Button[/button]</div>'); return is_singular('post') ? $button.$content.$button : $content; }Change the button shortcode attributes as per your need. Let us know how this gors!
January 6, 2017 at 6:50 pm #1319599
sandrayinParticipantHi Thanks! But can the top button be at the top of the post title? See attachment.
January 7, 2017 at 2:05 am #1319925
Rue NelModeratorHello There,
Thanks for updating in! To place the button on top of the title, please have the code updated and use this instead:
add_filter ('the_content', 'add_button_posts', 9999 ); function add_button_posts ( $content ) { $button = do_shortcode('<div style="text-align: right; margin: 5px 0;">[button type="flat" shape="pill" size="regular" href="#example" title="Example"][icon type="truck"]Pill Button[/button]</div>'); return is_singular('post') ? $content.$button : $content; } add_action('x_before_view_renew__content_post-header', 'add_button_before_title'); function add_button_before_title(){ if ( is_singular('post') ) { echo do_shortcode('<div style="text-align: right; margin: 5px 0;">[button type="flat" shape="pill" size="regular" href="#example" title="Example"][icon type="truck"]Pill Button[/button]</div>'); } }Please let us know if this works out for you.
January 7, 2017 at 10:32 am #1320224
sandrayinParticipantHi,
Sorry, it didn’t work. Now the top button disappeared.
January 7, 2017 at 11:43 pm #1320772
RadModeratorHi there,
I checked your other threads but I’m not sure which page you’re having this issue. Would you mind providing the exact URL? Maybe we could fix it by adding a javascript.
Thanks!
January 8, 2017 at 12:33 am #1320804
sandrayinParticipantThis reply has been marked as private.January 8, 2017 at 3:51 am #1320912
Rue NelModeratorHello There,
Sorry if the code did not work out. There was a typo error in the code. I already updated it and now the button appears before the post title.
Please check your site now.
January 18, 2017 at 2:03 am #1334677
sandrayinParticipantThank you!
January 18, 2017 at 2:15 am #1334687
ChristopherModeratorYou’re welcome.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1318849 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
