Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #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 here

    Alternatively, 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 the sidebar.php
    And then I took a look at sidebar.php but couldn’t figure out how to add an element to a specific sidebar.
    The file sidebar.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.
    #1218294

    Hey 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' );

    2020-05-31_181426.png
    Please double check your code or include an admin login so we can take a look.

    Best regards,
    Mike

    #1218379

    After 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.

    #1218414

    Hi,
    Yes, I did select “Festival Sidebar” in the Edit page, Layout > Sidebar Setting > Festival Sidebar, and ensure that Enfold Theme Options > Sidebar Settings > Sidebar on archive pages is selecting a sidebar,
    2020-05-31_185855.png
    I’m pretty sure that was the only other step I took.

    Best regards,
    Mike

    #1218482

    The 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 Pages

    I 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?

    #1218741

    Hi,
    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,
    Mike

    #1218826

    Thanks, 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?

    Widgets Page

    • This reply was modified 4 years, 11 months ago by vlamp.
    #1219025

    Hi,
    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,
    Mike

    #1219256

    Thanks, here’s the screenshot:

    Widgets page

    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.
    #1219765

    Hi,
    Thanks for the screenshot, so do you mean the yellow “!” in the widget?
    2020-06-05_060429.png
    this is because the widget is empty, there is nothing to worry about.

    Best regards,
    Mike

    #1219865

    Oh, 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.

    #1220075

    Hi,
    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,
    Mike

    #1220076

    Yeah 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.

    #1220111

    Hi,
    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,
    Mike

    #1220117

    Yeah, sounds good. Thanks for the help, I appreciate it :)

    #1220174

    Hi,
    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

Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Editing a custom Sidebar Menu’ is closed to new replies.