Skip to:
Content
Pages
Categories
Search
Top
Bottom

Conditionally loading sidebars

  • @xrun

    Member

    Hi.
    I’m working on customizing and buddypressifying :p a theme for a site I’m working on, and I need to display the sidebars on the page when the users click “View” on a single activity update in the stream. That takes them to that single activity, and no sidebars are loaded in this case.
    I need a little help with this.

    I’m guessing if I add the sidebars to the entry.php uncontitionally they’ll probably show up everywhere else where entries are shown as well, making sidebars show up twice instead of once in most cases, and in strange places.
    I need to load them only when viewing a single entry directly, by checking if sidebars are loaded, and if not: then load them.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @mercime

    Participant

    You will need to go over the conditional tags for WordPress and BuddyPress sections
    https://codex.buddypress.org/developer-docs/conditional-template-tags/
    https://codex.wordpress.org/Conditional_Tags

    @xrun

    Member

    Perfect, got it solved using this:

    !–
    Check to see if this is a single post or entry shown,
    and conditionally load first sidebar if it is.

    ?php if (bp_is_activity_permalink()) { ?
    div class=”left-sidebar”
    ?php locate_template( array( ‘left-sidebar.php’ ), true ) ?
    /div
    div class=”center-blog”

    ?php } ?
    !– End check to see if this is a single post or entry shown —

    (code clamps removed to show the code here.)
    And similar for every element needed shown under certain conditions.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditionally loading sidebars’ is closed to new replies.
Skip to toolbar