Skip to:
Content
Pages
Categories
Search
Top
Bottom

Condition in Sidebar.php


  • echiomega
    Participant

    @echiomega

    Hey everyone, my problem is that i want to add a condition to my sidebar to only display the chatbox I want to embed when it’s a single page view. Here’s the code that i tried.

    `<?php if (is_single() == true){
    Chat
    }
    ?>`

    Is it because adding this condition in sidebar.php the problem and if is, is there anyway i can embed a chat only during single.php view?

    Edit: Sorry for posting in wrong section of the forum. Too bad i can’t change it’s location….

Viewing 5 replies - 1 through 5 (of 5 total)

  • echiomega
    Participant

    @echiomega

    Never mine, i found a way to do this by creating another sidebar and call it with this code:

    If anyone has a better way then this then please reply.

    Your is_single() test should work, and it doesn’t require the ‘== true’ it returns true or false so if( is_single() ) will return true if on a single.php view.


    echiomega
    Participant

    @echiomega

    But will it work if i execute it in sidebar.php? Because i tried and it didn’t work.

    Yes it will or at least it shouild do. The sidebar.php is generally called from the individual files. In my single.php I call get_sidebar() thus I’m on a single page calling the sidebar – works for me anyhow :)


    echiomega
    Participant

    @echiomega

    Well i tried in my bp-default theme sidebar.php and it just display a blank sidebar. Anyway here’s the code, see any mistakes?

    `<?php
    if (is_single()) {

    Chat Box

    Chat
    }
    ?>`

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Condition in Sidebar.php’ is closed to new replies.
Skip to toolbar