Support » Fixing WordPress » Make something only show on post, not on main page?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Template_Hierarchy should help.

    This also might be a bit more valuable
    http://codex.wordpress.org/Conditional_Tags

    I’m really new to using conditional tags. How do I implement them say on my conditional include, if it’s on a single page, rather than the main template? Thanks.

    I guess what I would use… is_single()

    My question is how do I call this query? I’ve never really used php before.

    I want to call a div with other html inside it. So would I call the query is_single() and then put the html after that? How does that work?

    Thanks!

    Down about 3/4 of the page there is a is_single code example. You’ll want to use something like this where you want the content to show up:

    if (is_single())
    {
         echo 'This is just one of many fabulous entries in the ' . single_cat_title() . ' category!';
    }

    I’m not completely familiar with them either but it’s not too complicated. Play around with it and you’ll figure it out.

    If you use the single.php (the template file for displaying the single post view) you don’t need any kind of conditionals. That’s an overkill and absolutely not required to make it work.

    Put whatver code/text you want ONLY in the single.php file and it will be shown only in single post view. That’s it. Any advice saying otherwise is wrong…

    Moshu, but it looks like the subscribe content is in his sidebar. If you don’t want something to show just on the main page but everywhere else you will probably want to us something like is_front_page(). Your code would look something like

    if (is_front_page()){
        echo '';
    }else{
        echo 'whatever you want returned here';
    }

    If I understand the conditional correctly, this will echo nothing if it is front page and return your promo if any other page, such as page 2 of your blog,.

    @jonathanmead
    You could also create a new sidebar.php (eg. sidebar-single.php = copy the existing sidebar.php with the code for the subscribe content), delete <?php get_sidebar(); ?> in your single.php and simply include the new sidebar with:
    <?php include (TEMPLATEPATH . '/sidebar-single.php'); ?>.
    Then all sites of your blog will have the standard sidebar and only the single-sites the new one (donĀ“t forget to delete the subscribe code on the original sidebar.php).
    With this method you can create easily various sidebars for categories, pages etc..
    Sometimes this method is easier to handle for newbies.

    Actually, the content I wan to show up is only on the actual post page. Right now it’s showing up on the main page, whether I use the “more” function or not.

    It’s not for sidebar purposes.

    I don’t have a single.php. I guess the person that made my theme didn’t use it.

    Skaufman, I’ll try your suggestion. That sounds like it should work for me. So you can put anything within those single quote (‘) marks? Even html?

    Sorry if I sound like a total noob. =)

    Yes, echo sort of means “print this”. Only non-php can go there such as HTML or text, if you want more PHP in the middle of your echo you need to end the echo, insert PHP, then start the echo again to print the rest of your content all between the { } brackets.

    If you need that and can’t figure it out, just post it here. I’ll take a look at it.

    1. Everybody should learn to read correctly the post they are answering to. Quote:

    Okay, so I have this “subscriber promotion” box I made to include in each post, at the bottom.

    2. You are all overcomplicating it with php, conditionals and other crap.

    3. Save your index.php as single.php. Edit it (add the box and whatever). Done.

    Thank you Moshu and everyone else.

    I’m starting to get the hang of this now. =)

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Make something only show on post, not on main page?’ is closed to new replies.