Only show feature image and not image in content

Community Forums Forums Design Tips and Tricks Only show feature image and not image in content

This topic is: not resolved

Tagged: 

This topic contains 2 replies, has 1 voice, and was last updated by  Treefungus 1 year, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11851

    Treefungus
    Participant
    Post count: 51

    Hi

    I have successfully managed to put my image before content on this site http://bestapp.tv/test-test-test/

    by using this code

    /** Add custom field above page */
    add_action( ‘genesis_before_content’, ‘littledevil_page_image’ );
    function littledevil_page_image() {
    if ( $image = genesis_get_image( ‘format=url&size=post-photo’ ) ) {
    printf( ‘<a href=”%s” rel=”bookmark”><img class=”page-photo” src=”%s” alt=”%s” /></a>’, get_permalink(), $image, the_title_attribute( ‘echo=0′ ) );
    }

    }

    but I want it to only be the feature image and if I do not set a feature image then no image should be put in that area.

    Is this possible? Or will it always fall back on the content image if no feature image is set?

    • This topic was modified 1 year, 7 months ago by  Treefungus.
    • This topic was modified 1 year, 7 months ago by  Treefungus.
    • This topic was modified 1 year, 7 months ago by  Treefungus.
    • This topic was modified 1 year, 7 months ago by  Treefungus.
    #11865

    Treefungus
    Participant
    Post count: 51

    Ok I have tried something new which is this code. I am now only picking up post_thumbnail

    /** Add custom field above page */
    add_action( ‘genesis_before_content’, ‘littledevil_page_image’ );
    function littledevil_page_image() {
    if ( has_post_thumbnail() )
    the_post_thumbnail( ‘full’ );
    echo ‘<div class=”imgfeatured”>’;
    echo ‘</div>’;

    }

    but my styling is not working. I cannot seem to remove my styling that I have made to normal images using img class. I want this specific image to have the imgfeatured style.

    Any help is appreciated.

    Thanks

    #11879

    Treefungus
    Participant
    Post count: 51

    Also tried this but still cannot give it my own div class

    /** Add custom field above page */
    add_action( ‘genesis_before_content’, ‘littledevil_page_image’ );
    function littledevil_page_image() {
    if ( has_post_thumbnail() ){
    echo ‘<div class=”imgfeatured”>’;
    echo the_post_thumbnail( ‘full’ );
    echo ‘</div><!– end .imgfeatured –>’;
    }
    }

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

You must be logged in to reply to this topic.