• Resolved Ike Ten

    (@ike-ten)


    Hi Tom,

    Feature Request:
    The ability to set images as background of the posts (behind title and meta) would be a nice addition to WP Show posts.

    Is there a way to achieve this currently with a code snippet?

    Thanks.

    • This topic was modified 8 years ago by Ike Ten.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Tom

    (@edge22)

    This is a future feature of the pro version.

    You can definitely do it, you just need to target the element and write some CSS that will grab the featured image URL using PHP.

    You can hook your CSS into the wp_head hook so you can include PHP in the CSS.

    Let me know if you need more info ??

    Thread Starter Ike Ten

    (@ike-ten)

    Thanks Tom and good to know you already planned this feature ahead.

    Yes a simple example code to build on will do.

    Plugin Author Tom

    (@edge22)

    You could try something like this:

    add_action( 'wpsp_before_wrapper','tu_featured_image_background' );
    function tu_featured_image_background()
    {
        $url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
        if ( '' !== $url ) : ?>
            <style>
                .your-element {
                    background-image: url( '<?php echo $url; ?>' );
                }
            </style>
        <?php endif;
    }
    • This reply was modified 8 years ago by Tom.
    Thread Starter Ike Ten

    (@ike-ten)

    Thanks am trying it now.

    Thread Starter Ike Ten

    (@ike-ten)

    Hi Tom it works but strangely they all have the same featured image as background from the first most recent post.
    Am using the class of .wp-show-posts-inner and have deactivated the image from settings

    Thread Starter Ike Ten

    (@ike-ten)

    Also the featured image URL don’t show; instead it returns the post title; when the wp-show post short code inserted into page.
    Example :
    `.wp-show-posts-inner {
    background-image: url(https://example.com/post-title/);
    }`

    The issue with the same featured image occurs when I insert the code in the Blog Page Header Content. Am troubleshooting now and partly running in circles….

    • This reply was modified 8 years ago by Ike Ten.
    • This reply was modified 8 years ago by Ike Ten.
    • This reply was modified 8 years ago by Ike Ten.
    Thread Starter Ike Ten

    (@ike-ten)

    I Resolved it by using custom loop to call posts.

    Thanks for the code suggestion.

    It really showed me more creative ways to target elements.

    Plugin Author Tom

    (@edge22)

    Awesome! Glad you got it working ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Set Image As Background of post’ is closed to new replies.