
-
AuthorPosts
-
May 28, 2020 at 11:04 pm #1217537
How do I add a link at the end of the sidebar that will appear for all pages that uses this sidebar?
I was able to add a new custom widget area through Appearance > Widgets > Add Widget Area
Then, I selected the new sidebar widget in the webpage, Edit Page > Sidebar Setting – selected the new sidebar hereAlternatively, I had attempted inserting this code in the functions.php, following the instructions from wordpress documentations with my own information:
function my_register_custom_sidebars() { /* Register the 'festival' sidebar. */ register_sidebar( array( 'id' => 'festival', 'name' => __( 'Festival Sidebar' ), 'description' => __( 'Custom sidebar for the festival pages' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); /* Repeat register_sidebar() code for additional sidebars. */ } add_action( 'widgets_init', 'my_register_custom_sidebars' );
'after_widget' => '<div>custom link goes here</div></div>',
When I added the link to the after_widget, it didn’t work, so I suspected that I needed to go through thesidebar.php
And then I took a look atsidebar.php
but couldn’t figure out how to add an element to a specific sidebar.
The filesidebar.php
hasn’t been touched so it is in its original form, which I copied over to the enfold-child theme.//global sidebar if (dynamic_sidebar('Displayed Everywhere')) : $default_sidebar = false; endif; if (dynamic_sidebar('festival')) { echo "<div>custom link goes here</div>"; }
This link element is a weblink to an external site, so it is not like the autogenerated list of pages above it, all I need to do is hard code the html dom element somewhere.
-
This topic was modified 4 years, 11 months ago by
vlamp.
June 1, 2020 at 12:18 am #1218294Hey vlamp,
I tested your code to create a sidebar with a hardcoded link in my child theme functions.php and it works for me:function my_register_custom_sidebars() { register_sidebar( array( 'id' => 'festival', 'name' => __( 'Festival Sidebar' ), 'description' => __( 'Custom sidebar for the festival pages' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '<div><a href="#">custom link goes here</a></div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } add_action( 'widgets_init', 'my_register_custom_sidebars' );
Please double check your code or include an admin login so we can take a look.Best regards,
MikeJune 1, 2020 at 9:27 am #1218379After adding that code, did you select “Festival Sidebar” in the Edit page, Layout > Sidebar Setting > Festival Sidebar
What other steps have you taken? I’m trying to figure out if I skipped something.
I’ll provide the admin info shortly if I followed the steps correctly.
June 1, 2020 at 12:19 pm #1218414June 1, 2020 at 5:53 pm #1218482The settings I have on Sidebar settings are as follows:
Sidebar on Archive Pages > right sidebar
Sidebar on Blog Page > no sidebar
Sidebar on Single Post Entries > no sidebar
Sidebar on Pages > left sidebar
Separate Sidebars for Blog and Archive Pages > Show Blog Sidebar on Archive PagesI have configured those settings after my client’s requests which had been showing the sidebars correctly. But with this new addition to the sidebar, do I need to change something here?
June 2, 2020 at 11:32 am #1218741Hi,
Thanks for the login, I checked your sidebar and it seems you must have a widget in it for it to show, I added an empty “custom HTML” widget and now it shows.
Although you have two of them showing, probably another customization you made because it only shows once on my localhost.
Please check.Best regards,
MikeJune 2, 2020 at 6:42 pm #1218826Thanks, I was able to clean up my other attempts and now it is showing the custom link properly. I have three questions though:
1. Is it correct to assume that I cannot append to the list of pages (inside the
<ul>
), but only add a custom widget below it?
2. In the Appearance > Widgets > Custom HTML, you’ve selected Displayed Everywhere. Is it more accurate if I choose Festival Sidebar there?
3. Can you explain what’s happening in the screenshot and if I need to clean it up?-
This reply was modified 4 years, 11 months ago by
vlamp.
June 3, 2020 at 12:28 pm #1219025Hi,
1. You can append the list with javascript, but the way you are doing it will probably use less resources
2. When I check the Custom HTML is inside the Festival Sidebar, this seems correct.
3. I can’t see your screenshot, please try uploading your screenshots here and posting the links in your post.Best regards,
MikeJune 3, 2020 at 10:44 pm #1219256Thanks, here’s the screenshot:
I’m not sure if you can see if or not, if not, you can go directly to the address, https://savvyify.com/img/images/2020/06/03/Screen-Shot-2020-06-02-at-9.54.00-AM.png
-
This reply was modified 4 years, 11 months ago by
vlamp.
June 5, 2020 at 12:08 pm #1219765June 5, 2020 at 5:54 pm #1219865Oh, I meant to ask if it is more accurate to choose Festival Sidebar under Appearance > Widgets > Custom HTML, where currently it’s selecting Displayed Everywhere.
There’s also two widgets shown to the right, Displayed Everywhere and Festival Sidebar with blank content in the custom HTML, so is any of them an unused widget that I need to remove?
Thank you so much for the support by the way, I’m glad to have this working quickly.
June 6, 2020 at 9:26 pm #1220075Hi,
Ok, I think we are not talking about the same things, so in the screenshot in the Private Content area, the area in the red box is where the available widgets are, but the green box is where the used widgets are.
I hope this makes since.Best regards,
MikeJune 6, 2020 at 9:29 pm #1220076Yeah I understand that. So I’m asking if the “cleanup” needs to be done in the green area. Also, I was noting that Displayed Everywhere can be selected from the red area, which is then reflected in the green area.
June 7, 2020 at 4:39 am #1220111Hi,
no “cleanup” needs to be done in the green area, selecting Displayed Everywhere from the red area will create a new widget, it is not a control for a widget that is already in place. The goal was to have the Custom HTML inside the Festival Sidebar so the link will show, correct?Best regards,
MikeJune 7, 2020 at 4:58 am #1220117Yeah, sounds good. Thanks for the help, I appreciate it :)
June 7, 2020 at 12:08 pm #1220174Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)Best regards,
Mike -
This topic was modified 4 years, 11 months ago by
-
AuthorPosts
- The topic ‘Editing a custom Sidebar Menu’ is closed to new replies.