Grow your CSS skills. Land your dream job.

WP – Clickable featured image

  • # September 22, 2011 at 3:54 am

    Hi

    I have a question on how to make my featured image clickable.

    example
    http://www.nordarchitects.dk/featured/healthcare-center/

    On this page i would very much like to be able to activate the gallery by clicking the featured image.

    Is there any way to do this?

    Thanks
    Simon

    # September 22, 2011 at 11:15 am

    Oooooo an interesting query.

    You probably can, though the ease of that depends on how your page is currently structured. Can you post the code for the template in question?

    # September 23, 2011 at 9:43 am

    Here’s the code for my single page template.
    Let me know if you need more.



    < ?php get_header(); ?>



    < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>






    < ?php the_title(); ?>





    < ?php the_post_thumbnail ('large');
    echo get_post(get_post_thumbnail_id())->post_excerpt; ?>



    < ?php the_content(); ?>



    < ?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>

    < ?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries ?>


    < ?php endif; ?>

    < ?php endwhile; // end of the loop. ?>



    < ?php get_footer(); ?>
    # September 23, 2011 at 12:47 pm

    I feel like you could do something like:

    " rel="fancybox">< ?php the_post_thumbnail('large'); ?>
    # September 23, 2011 at 2:13 pm

    Isn’t the easiest way to do it just to wrap the thumbnail in the permalink?

    " />
    < ?php the_post_thumbnail ('large'); ?>
    # September 23, 2011 at 2:59 pm

    @Johnnyb – he’s trying to open up the lightbox, not link to the page that you’re already on.

    # September 27, 2011 at 2:11 pm

    hmmm…it doesn’t seem to work.

    @TheDoc

    " rel="fancybox">< ?php the_post_thumbnail('large'); ?>

    clicking the featured img now reloads the page and doesn’t activate the fancybox.

    …any suggestions?

    Simon

    # September 27, 2011 at 2:22 pm

    Blast. Okay, give this one a go:

    " rel="fancybox">< ?php the_post_thumbnail('large'); ?>
    # September 27, 2011 at 4:37 pm

    Still the same I’m afraid.

    Do you think i’m doing simething wrong?



    < ?php get_header(); ?>



    < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>






    < ?php the_title(); ?>








    < ?php the_content(); ?>




    < ?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>

    < ?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries ?>


    < ?php endif; ?>

    < ?php endwhile; // end of the loop. ?>



    < ?php get_footer(); ?>
    # September 27, 2011 at 6:26 pm

    What is it outputting?

    # September 28, 2011 at 3:24 am

    The same as before – it reloads the page when clicking the featured image

    # September 28, 2011 at 5:23 pm

    I meant the HTML, but I was able to check.

    Are the images not attached to the post? How are you creating the gallery via the built-in WordPress functionality?

    # September 29, 2011 at 3:56 am

    ok.

    The images are attached as a gallery inside the post, and the fancybox is a wp-plugin.

    # September 29, 2011 at 2:34 pm

    Well, I’d say this is my final suggestion. I have no idea why it wouldn’t be working:
    ID); ?>">

    # September 30, 2011 at 12:19 pm

    It doesn’t work either i’m afraid.

    too bad

    I guess it has something to do with the plug-in?


    < ?php get_header(); ?>



    < ?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>






    < ?php the_title(); ?>








    < ?php the_content(); ?>




    < ?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>

    < ?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries ?>


    < ?php endif; ?>

    < ?php endwhile; // end of the loop. ?>



    < ?php get_footer(); ?>
Viewing 15 posts - 1 through 15 (of 19 total)

The topic ‘WP – Clickable featured image’ is closed to new replies.

*May or may not contain any actual "CSS" or "Tricks".