Grow your CSS skills. Land your dream job.

Adding permalink to thumbnail

  • # August 22, 2014 at 12:21 am

    In wordpress I have the following code:

     <div class="blog-elegant-right">
                                <?php                            
                                // thumbnail
                                if ( $has_thumbnail ) {
                                    echo apply_filters( 'yiw-loop-blog-elegant-thumbnail', get_the_post_thumbnail( get_the_ID(), 'blog_elegant' ) );
                                }
                                
                                // content
                                add_filter( 'excerpt_more', create_function( '$more', 'return "<br /><br /><a class=\"more-link\" href=\"'. get_permalink( get_the_ID() ) . '\">' . yiw_get_option('blog_read_more_text') . '</a>";' ) );
                                if( !is_single() OR get_post_type() == 'bl_testimonials' ) {
                                        the_excerpt( str_replace( '->', '&rarr;', yiw_get_option('blog_read_more_text') ) ); 
                                }
                                ?>
                                </div>

    Which gets the post thumbnail and excerpt. I didn’t build this by the way. Don’t know much about php.

    I need the thumbnail to link to the post and I’d like a read more at the end of the excerpt.

    How do I do this?

    # August 22, 2014 at 7:16 am

    You want to look further into the theme.

    Somewhere, you’ll find the HTML that has referenced yiw-loop-blog-elegant-thumbnail – just do a ctrl-f (or in OSX command-f) for it in each file, you’ll get it eventually.

    # September 8, 2014 at 1:26 am

    This is all you need to do:
    Within the loop you can just use this code <?php echo get_permalink(); ?>

    This code gets the link for the current post.

    And you can use that code to link thumbnails to the post like this:
    <a href="<?php echo get_permalink(); ?>"><img src="img/pic.jpg" alt="image" /></a>
    <code></code>

    I hope you get the idea.

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

You must be logged in to reply to this topic.

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