-
AuthorPosts
-
September 6, 2023 at 2:58 am #1418222
I have a few hundred posts written, a hundred or so published. I need to put a “back to the blog” button at the bottom of all of them, and ideally have it automatically placed on all future posts. I don’t want it in the footer though, just at the very end of each post. I can go in and paste it in manually a few hundred times, but if there is a custom CSS or widget that goes on the bottom of the main body (not in the sidebar) of posts that will save my fingers a great deal of repetitive motion.
Thanks!
JonSeptember 6, 2023 at 6:41 am #1418240Hey gatehealing,
Thank you for the inquiry.
If you are using the default editor to create the content of the posts, you can just add this code in the functions.php file to add extra elements below the post content.
add_action("ava_after_content", function() { if (is_singular('post')) { echo "<div class='av-back-to-blog-link'><a href='#'>Back to Blog</a></div>"; } }, 10);
Just replace the href attribute value with the actual blog URL.
Best regards,
IsmaelSeptember 6, 2023 at 7:21 pm #1418294Thanks, we are getting closer. This text seems to straddle the social share buttons at the bottom of the post. “Back to” is above the share buttons and aligned to the right margin; “Blog” is after the share buttons and aligned to the left.
If it’s not terribly difficult, I’d prefer for it to be centered and above those social share buttons. I can turn it into a green button that matches the rest of my site using the element code if you can tell me where to insert it in your code.
Thanks!
JonSeptember 7, 2023 at 6:54 am #1418327Hi,
Thank you for the update.
We may need to inspect the site in order to provide a proper solution. Please post the site URL in the private field.
Best regards,
IsmaelSeptember 7, 2023 at 9:27 pm #1418405Here ya go:
September 10, 2023 at 1:35 am #1418626Hi,
Thank you for the link to your site but I’m not seeing the link at the bottom of the page and searching for Back to found nothing, is the above code activate?Best regards,
MikeSeptember 10, 2023 at 1:51 am #1418627Yes, I removed it because it looked bad/unprofessional.
I’ll put it back in now.September 10, 2023 at 1:57 am #1418628ok, it’s back…you can see it now
September 10, 2023 at 2:26 am #1418630September 10, 2023 at 2:54 am #1418631Do I leave the code in Functions.php?
For me to turn that into a button instead of just a link, would I just insert the code that shows up for a button when I use the magic wand in the Post editors in the Functions.php code?
September 10, 2023 at 5:59 pm #1418664Hi,
If you are using a child theme then yes leave the code in the functions.php, otherwise I recommend the WPcode plugin this plugin supports PHP code snippets, JavaScript code snippets, & CSS code snippets and you will not lose your code when you update as you would if the code is in your parent theme functions.php.
To change it into a button using the magic wand in the Post editors we will need to change the function a little to use do_shortcode
Here is an example that I tested on my yest site and works, you can change the button code to suit your needs:add_action("ava_after_content", function() { if (is_singular('post')) { echo do_shortcode("[av_button label='Back to Bolg' icon_select='yes' icon='ue830' font='entypo-fontello' icon_hover='aviaTBicon_hover' link='manually,#' link_target='' size='medium' position='center' label_display='' title_attr='' size-text='' av-desktop-font-size-text='' av-medium-font-size-text='' av-small-font-size-text='' av-mini-font-size-text='' margin='' margin_sync='true' padding='' padding_sync='true' av-desktop-margin='' av-desktop-margin_sync='true' av-desktop-padding='' av-desktop-padding_sync='true' av-medium-margin='' av-medium-margin_sync='true' av-medium-padding='' av-medium-padding_sync='true' av-small-margin='' av-small-margin_sync='true' av-small-padding='' av-small-padding_sync='true' av-mini-margin='' av-mini-margin_sync='true' av-mini-padding='' av-mini-padding_sync='true' color_options='' color='theme-color' custom_bg='#444444' custom_font='#ffffff' btn_color_bg='theme-color' btn_custom_grad_direction='vertical' btn_custom_grad_1='#000000' btn_custom_grad_2='#ffffff' btn_custom_grad_3='' btn_custom_grad_opacity='0.7' btn_custom_bg='#444444' btn_color_bg_hover='theme-color-highlight' btn_custom_bg_hover='#444444' btn_color_font='theme-color' btn_custom_font='#ffffff' btn_color_font_hover='white' btn_custom_font_hover='#ffffff' border='' border_width='' border_width_sync='true' border_color='' border_radius='' border_radius_sync='true' box_shadow='' box_shadow_style='0px,0px,0px,0px' box_shadow_color='' animation='' animation_duration='' animation_custom_bg_color='' animation_z_index_curtain='100' hover_opacity='' sonar_effect_effect='' sonar_effect_color='' sonar_effect_duration='1' sonar_effect_scale='' sonar_effect_opac='0.5' css_position='' css_position_location=',,,' css_position_z_index='' av-desktop-css_position='' av-desktop-css_position_location=',,,' av-desktop-css_position_z_index='' av-medium-css_position='' av-medium-css_position_location=',,,' av-medium-css_position_z_index='' av-small-css_position='' av-small-css_position_location=',,,' av-small-css_position_z_index='' av-mini-css_position='' av-mini-css_position_location=',,,' av-mini-css_position_z_index='' id='' custom_class='' template_class='' element_template='' one_element_template='' av_uid='' sc_version='1.0' admin_preview_bg='']"); } }, 10);
Best regards,
MikeSeptember 10, 2023 at 7:13 pm #1418672Thanks! That worked great!
Feel free to close this thread.J
September 10, 2023 at 7:29 pm #1418673Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Is it possible to place a button at the bottom of all blog posts?’ is closed to new replies.