Support » Plugin: Display Featured Image for Genesis » How to customize title (adding an anchor) over featured image

  • Resolved gvdplas

    (@gvdplas)


    Dear Robin,

    I have been stuck for a while doing something I think should be very simple: I want to output a ‘scroll down’ anchor directly after the page title (which is overlayed on the stretched featured image).

    I manage to do this by hacking into the plugin files (for example, by editing line 38 of the file class-Display_Featured_Image_Genesis_Description.php into –>

    $headline = sprintf( ‘<h1 class=”entry-title”%s>%s</h1><div><span class=”dashicons dashicons-arrow-down-alt”></span></div>’, $itemprop, get_the_title() );

    However, I have not been able to do this using a filter put in my functions.php (probably the “display_featured_image_genesis_title” one?). Is what I want to do possible? And if so, can you point me in the right direction?

    Thank you very much for this very useful plugin!

    • This topic was modified 4 years, 2 months ago by gvdplas.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    Instead of using a filter, I would use an action hook, so your arrow will just be output directly instead of being returned (it may be being stripped out by the filter you are using). display_featured_image_genesis_after_title will output directly after the <h1> element overlaying a backstretch image. You should be able to add your arrow there. Hope that helps get you started!

    Thread Starter gvdplas

    (@gvdplas)

    Hi Robin,

    Thank you very much for your reply!

    Using display_featured_image_genesis_after_title will output code outside the .excerpt class, which I don’t want. I have managed to get partially what I want using a filter on display_featured_image_genesis_modify_title_overlay and replacing the </h1> string with [mycode]</h1>.

    However this only works for me while the “Move Excerpts/Archive Descriptions” functionality is not active (which I don’t want).

    Long story short, I’ll keep learning and trying. Thanks again for your time!

    Plugin Author Robin Cornett

    (@littlerchicken)

    Sorry, I did not realize you were using the excerpts option. In that case, there is a dynamic hook displayfeaturedimagegenesis_before_{$context} which you can use. On singular posts/pages, it should be displayfeaturedimagegenesis_before_excerpt, for example. This will output before the excerpt text, but inside of the .excerpt div.

    Does that help you get closer to what you want?

    Thread Starter gvdplas

    (@gvdplas)

    Hi Robin,

    It sure does, thanks!

    I am not quite there yet and have to abandon this project for the coming ~weeks but am sure I’ll make it out. Thanks again for all your help!

    Thread Starter gvdplas

    (@gvdplas)

    ps, for the interested reader, you can see the desired arrow imposed over the featured image below the page title on the following page: http://urlgone.com/1e2bfc/

    For now that is done by directly adding an extra line after line 38 of the Display_Featured_Image_Genesis_Description.php file. The new line is: ` $headline = str_replace(‘</h1>’, ‘</h1><div class=”animated bounce”><a href = “#genesis-content”><span class=”dashicons dashicons-arrow-down-alt”></span></a></div>’, $headline);
    `

    Plugin Author Robin Cornett

    (@littlerchicken)

    Another approach which will add the arrow after the headline and excerpt overlaying a featured image:

    
    add_action( 'displayfeaturedimagegenesis_after_excerpt', 'prefix_add_arrow_after_excerpt' );
    /**
     * Add a "skip to content" link/arrow after the featured image excerpt.
     */
    function prefix_add_arrow_after_excerpt() {
    	echo '<div class="animated bounce"><a href="#genesis-content"><span class="dashicons dashicons-arrow-down-alt"></span></a></div>';
    }
    
    Thread Starter gvdplas

    (@gvdplas)

    Wow, that works like a charm. I have in the meantime spend quite some fruitless lines of codes to get there, thanks for looking back into an already marked as ‘resolved’ topic!

    For general interest as for the animated small arrow: I have noticed that it does lower the bouncerate a bit because it makes abundantly clear that there is *more* than a pretty picture (which not may load directly depending on speed).

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to customize title (adding an anchor) over featured image’ is closed to new replies.