Hooks + PHP

This topic is: not resolved

Tagged: , , ,

This topic contains 4 replies, has 3 voices, and was last updated by  Sridhar Katakam 10 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #67121

    dawnbar
    Participant
    Post count: 4

    Hi there,

    Can someone help?

    Using hooks to add some images after post content – and all is dandy, looks lovely. :-)

    However, using Outreach and the content I’ve added is showing on the home page, which looks silly (but still lovely!)

    I am using this:

    <?php if(is_single()) { ?>
    <div>
    mystuff
    <?php } ?>

    And it’s the <?php if(is_single()) { ?> part that I can’t get my head around.

    To exclude this php function on the home/front page and still include it after single posts only (not pages), how is written? Oh and do I need to end the code in a different way?

    Can anyone help. Have no idea how to write php, I usually find in here an answer. I have no idea if the above makes sense, but it does to me!

    Many thanks,

    Dawn

    #67129

    vabmedia
    Participant
    Post count: 1

    yes, end the code with } ?>
    and you’re basically saying that if you are on a single blog post page { –//start executing this code– end the “if” php code } ?>

    #67130

    Sridhar Katakam
    Participant
    Post count: 958
    #67237

    dawnbar
    Participant
    Post count: 4

    Thank you both.

    Sridhar thank you, it’s not what I was wanting to do. But I have bookmarked your site. What a resource.

    I am sorry, but now seeing a little clearer…

    How would I say…

    if on single blog post show this // but not if on the home page (or front page)

    And how would I specifically end that?

    Many thanks for your time and getting me closer to lifting foggy php knowledge.

    Dawn

    #67271

    Sridhar Katakam
    Participant
    Post count: 958

    Try this:

    if ( is_single() ) { ?>
    
    	HTML here 	
    
    <?php }
    
    elseif ( is_home() || is_front_page() ) { ?>
    
    	HTML here 	
    
    <?php }

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

You must be logged in to reply to this topic.