Conditional Tags Question

Community Forums Forums General Discussion Conditional Tags Question

This topic is: not resolved

This topic contains 18 replies, has 2 voices, and was last updated by  PainterMommy 11 months, 4 weeks ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #63427

    PainterMommy
    Participant
    Post count: 48

    I am working on a site http://singletosmitten.com/ and I am using the Genesis hooks plugin to add a large graphic at the top of each page. We are using different graphics for each page. I am having trouble getting the blog graphic to show on the blog page.

    This is the code I am using but it isn’t working for me. I also tried the “single” conditional tag and that is not working either. #14 is the number of the blog page. Here is the link to the blog page – http://singletosmitten.com/blog/

    <?php
    if(is_page( 14 ) ) { ?>
    <center>

    </center>
    <?php }
    ?>

    Any ideas on how I can get the image to display correctly? I appreciate it.

    DAWN

    #63435

    braddalton
    Participant
    Post count: 9936

    I think you would be far better off creating a custom field for this if you plan on adding unique images before each page and/or page.

    This will add a new box to every edit screen where you can simply choose an existing image from your media library or upload a new image which is only display before the content on that post or page. http://wpsites.net/web-design/add-unique-header-images-using-custom-fields/

    You would need to change th hook in the code on that post from genesis_header to genesis_before_loop or genesis_before_content_sidebar_wrap.

    Or you can use this PHP code in your child themes functions.php file for one image

    https://gist.github.com/braddalton/6629292


    #63447

    PainterMommy
    Participant
    Post count: 48

    Because I already have the images on all the other pages, I went ahead and added the code you provided to the functions.php (for the blog page) and I am still not seeing the image on the blog page. Sigh… Any ideas?

    #63448

    braddalton
    Participant
    Post count: 9936

    Did you add the HTML for your image to the code between the div tags?


    #63452

    PainterMommy
    Participant
    Post count: 48

    Yes, here is the code I added:

    /** Add image before blog page */
    function image_before_blog() {
    if(is_page(blog) )
    echo ‘<div class=”custom-image”>http://singletosmitten.com/wp-content/uploads/2013/09/Marabeth-Banner-Blog_small.jpg</div&gt;’;
    };
    add_action(‘genesis_before_loop’, ‘image_before_blog’);

    #63499

    braddalton
    Participant
    Post count: 9936

    That won’t work as its simply a link to the image.

    You will need to insert the image into your editor and grab the HTML for the image which needs to be pasted between the div tags in my PHP code.


    #63542

    PainterMommy
    Participant
    Post count: 48

    Yes, that is what I did.

    #63560

    braddalton
    Participant
    Post count: 9936

    It looks like you only pasted the url and not the HTML. It it working?


    #63567

    PainterMommy
    Participant
    Post count: 48

    OK, I updated the code to include the html, but it still isn’t working. Here is the code:

    /** Add image before blog page */
    function image_before_blog() {
    if(is_page(blog) )
    echo '<div class="custom-image"><img src="http://singletosmitten.com/wp-content/uploads/2013/09/Marabeth-Banner-Blog_small.jpg"/></div>';
    };
    add_action('genesis_before_loop', 'image_before_blog');

    This is the page that I need the image to show up on: http://singletosmitten.com/blog/

    #63575

    braddalton
    Participant
    Post count: 9936

    If you have selected to use a static front page in your reading settings, then you can use the is_home() conditional tag for your blog page.

    Please change this line in your code from this:
    [php]
    if(is_page(blog) )
    [/php]

    To:
    [php]
    if(is_home() )
    [/php]


    #63587

    PainterMommy
    Participant
    Post count: 48

    The blog is not set as the homepage though. Does that make a difference?

    #63590

    braddalton
    Participant
    Post count: 9936

    The is_home() conditional works for displaying content on your blog page when you have selected a static page as your front page and your blog page as your posts page in your Reading Settings. http://wpsites.net/web-design/using-conditional-tags-for-home-front-blog-pages/#Blog_Page_Template


    #63645

    PainterMommy
    Participant
    Post count: 48

    Oh geez. Sorry about that. OK, I did that and things are a bit off. Can you check it out for me? http://singletosmitten.com/blog/

    #63646

    braddalton
    Participant
    Post count: 9936

    Looks like you have a problem with the hook position which you can change and the styling which you can change using the div class
    [css].custom-image[/css]


    #63651

    PainterMommy
    Participant
    Post count: 48

    I added the code in the functions.php. I am not sure what I need to adjust in order to get the page to look like it is supposed to. I wish I was better with code. I am still a novice so I appreciate any help / direction that you might have.

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.