WordPress.org

Ready to get started?Download WordPress

Forums

Prevent output from get_sidebar() without altering core files (2 posts)

  1. amp343
    Member
    Posted 3 years ago #

    I am trying to replace the output of get_sidebar() with that of my own function.

    I know I can tie into the "get_sidebar" hook, which is executed at the beginning of the get_sidebar() function, in order to alter the output. However, after that filter hook is executed, the rest of the get_sidebar() function still runs, and loads a sidebar (which I want to avoid).

    I guess my question is, after tying into this hook and generating some custom output, is there any way to prevent the rest of the function from running, or limit its output in any way?

    Here is a link to the contents of get_sidebar(), where you can see the sequence of the hook with respect to the original function.

    get_sidebar() function

    Any help is appreciated!

  2. mcdonna
    Member
    Posted 3 years ago #

    I agree, it would be nice to replace get_sidebar() with your own function. But here are a couple of alternatives:

    - edit the sidebar.php file to do whatever it is you want done in lieu of a sidebar

    or

    - replace the call to get_sidebar() with a call to your own function

Topic Closed

This topic has been closed to new replies.

About this Topic