• Resolved William

    (@rfdmwilliam)


    I am adding a new sidebar to my site to appear on blog single posts. I have followed the Sidebars Doc and have it working without any problems on my test site.

    The trouble is that once I move it to the live site, the Sidebar does not appear in the Admin Widgets area to add widgets. Below is the function in my child-theme’s functions.php.

    I can’t find any reason why wouldn’t be working, and the only difference between my test and live site would be caching with Autoptimize and W3 Total Cache. But even when clearing their caches nothing changes.

    function register_new_sidebar()
    {
      register_sidebar( 
        array(
          'name' => esc_html__('Article Sidebar', 'child-theme'),
          'id' => 'new-article-sidebar',
          'class' => 'article-sidebar',
          'description' => esc_html__('Sidebar appearing on blog post page.'),
          'before_widget' => '<aside id="%1$s" class="widget %2$s">',
          'after_widget' => '</aside>',
          'before_title' => '<h3 class="widget-title">',
          'after_title' => '</h3>',
        )
      );
    }
    add_action( 'widgets_init', 'register_new_sidebar' );
    • This topic was modified 3 years, 7 months ago by bcworkz. Reason: code fixed
Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @rfdmwilliam

    Could you share me your website access?
    I hope, need debug to find out proper issue.

    Thanks

    Moderator bcworkz

    (@bcworkz)

    @asraf123 – please do not ask for access to others sites in these forums. It is against our guidelines due to past abuse. I’m sure you mean well, but for everyone’s safety and to limit potential liability, that sort of assistance is not allowed. If a problem cannot be solved without site access, then it’s not a problem to be solved on these forums.

    William, if it worked on your test site, assuming your test site uses the same theme and plugins other than those noted, the problem is likely external to WP. Did you also clear your browser cache? The host could also have caching active outside of WP.

    Thread Starter William

    (@rfdmwilliam)

    Hi @bcworkz, this is my assumption as well. I’ve made sure to clear browser cache as well as my my WordPress’s Autoptimise and W3 Total Cache plugin’s and CDN.

    Even after 24 hours, the sidebar does not appear in my Admin Widgets area. I can’t think of where else it could be caching.

    • This reply was modified 3 years, 7 months ago by William.

    Thanks @bcworkz noted.

    Thread Starter William

    (@rfdmwilliam)

    I have done some testing and this is definitely an issue with the child-theme’s functions. Even though I have my child-theme styles enqueued, the functions in the same functions.php file do not run.

    Even changing the priority does not help.

    Any suggestions on where to find an override?

    Moderator bcworkz

    (@bcworkz)

    It could be a difference in PHP versions causing problems. If so, an error or warning why ought to be logged. I can confirm your code works correctly on my test site as well, but a PHP version conflict could lie anywhere in the file. If no clues are evident in the error log, try commenting out everything in the file but your sidebar code. It ought to work then. Uncomment half of the commented out code and determine which half contains the problem. Continue halving until the problem is narrowed down.

    You don’t have to literally halve code, but use some logical code disabling sequence to narrow down the problem. Crude and tedious, but it should help you find the problem.

    Thread Starter William

    (@rfdmwilliam)

    Good call, @bcworkz. There was indeed a return function in the code above that was causing the issue. Commenting and then removing it resolved the issue.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Dynamic Sidebar Not Displaying in Widget Area’ is closed to new replies.