• Resolved alexb268

    (@alexb268)


    Hi there,
    I am posting this after alot of coding changing with all the work has given me no solution. I want my archive.php ( category file ) to display Thumbnails with link to Original post.

    my archive.php file : http://www.pastebin.ca/3023861

    My function.php file : http://pastebin.ca/3023862

    Its been a week since I am searching for a solution. Would be grateful if anyone can help me out with this.

Viewing 9 replies - 1 through 9 (of 9 total)
  • this is the section of archive.php dealing with thumbnail images:

    <?php $thumb = tube_getcustomfield('wtp_thumb_url',get_the_ID()); if(!empty($thumb)) { ?>
                                        <img src="<?php echo $thumb; ?>" alt="<?php the_title_attribute(); ?>" width="180" height="140" /> <?php } else { ?>
                                        <img src="<?php bloginfo('template_url') ?>/images/pic_post1.jpg" width="180" height="140" alt="image" /><?php } ?>

    do you want to integrate the ‘featured image’ into that conditional statement with top priority, or do you wnat to grab the first image from the post?

    Thread Starter alexb268

    (@alexb268)

    Just want the first or any image to be the thumbnail.

    try to replace the earlier posted section with
    (partly based on http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it ):

    <?php //image section
    	  $first_img = '';
    	  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    	  if( $matches [1] ) $first_img = $matches [1] [0];
    	  if(!empty($first_img)) { ?>
    		<img src="<?php echo $first_img; ?>" alt="<?php the_title_attribute(); ?>" width="180" height="140" />
    	<?php } else {
    		//$thumb = tube_getcustomfield('wtp_thumb_url',get_the_ID());
    		if( !empty( $thumb ) ) { ?>
    		<img src="<?php echo $thumb; ?>" alt="<?php the_title_attribute(); ?>" width="180" height="140" />
    	<?php } else { ?>
    		<img src="<?php bloginfo('template_url') ?>/images/pic_post1.jpg" width="180" height="140" alt="no post image" />
    	<?php }
    	} ?>
    Thread Starter alexb268

    (@alexb268)

    Alright I’m give me a sec.:)

    Thread Starter alexb268

    (@alexb268)

    Works like a charm. 😀

    I added the same code to index file too and voila. Works on both places.

    Btw one last thing. Is there any possible way I can change replace the Title of the post to Category name its posted in ?

    change replace the Title of the post to Category name its posted in ?

    the code for the post title is on that section (in archive.php from 132):

    <div class="boxtitle">
                               <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo tube_get_limited_string($post->post_title,15); ?></a></h2>
                                    </div>

    to just show the name of (the first) category the post is posted in, try and change the section to:

    <div class="boxtitle">
                               <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php
    $post_cats = get_the_category();
    $cat_name = $post_cats[0]->cat_name;
    echo 'new '.$cat_name; ?></a></h2>
                                    </div>
    Thread Starter alexb268

    (@alexb268)

    Worked again.

    I right clicked on the images and saw this :

    500px × 375px (scaled to 180px × 140px)

    Is there a way I can generate the thumbnails to 149px × 111px.

    Thread Starter alexb268

    (@alexb268)

    I got it. Saw the earlier edit. Just need to change the dimensions. 🙂

    Thread Starter alexb268

    (@alexb268)

    Adding to all this You have been a really good help man. Thanks alot. I really mean it. btw do you know any simple way to make my wordpress mobile compatible ?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘make Archive.php file to display thumbnails of posts.’ is closed to new replies.