WordPress.org

Ready to get started?Download WordPress

Forums

Transform blog.php into archive-ish page (4 posts)

  1. leoahrens
    Member
    Posted 1 year ago #

    Hello world,

    I'm relatively new to this so a little help will go a long way...

    I need to transform this page from a blog page that displays all posts and has featured image thumbnails into a page that only displays 'category_name=news-events' and eliminates the featured thumbnail. I want all the post content to display right after the last post. But each post still has a Title and meta data. More of a classic blog style. Hopefully that makes sense...

    <?php
    /*
    	Template Name: CatBlog
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="casing">
    
    <div class="incasing">
    
    <div id="content">
    
    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('paged='.$paged);
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <div class="title">
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <div class="postmeta">
    	<span class="author">Posted by <?php the_author(); ?> </span> <span class="clock">  <?php the_time('M - j - Y'); ?></span> <span class="comm"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments'); ?></span>
    </div>
    
    <div class="entry">
    
    <?php
    if ( has_post_thumbnail() ) { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=500&w=980&zc=1" alt=""/></a>
    <?php } else { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>
    <div class="clear"></div>
    </div>
    
    </div>
    
    <?php endwhile; ?>
    
    <div class="clear"></div>
    
    <?php getpagenavi(); ?>
    
    <?php $wp_query = null; $wp_query = $temp;?>
    
    </div>
    
    <div class="clear"></div>
    
    </div>
    
    <div class="clear"></div>
    </div>	
    
    <?php get_footer(); ?>
  2. leoahrens
    Member
    Posted 1 year ago #

    I changed one of the top lines to...

    $wp_query->query('category_name=news-events.','paged='.$paged);

    and that singled out the posts I want. Now I need to get rid of the post thumbnail fuction so it automatically displays all post content....

    Please help!
    Thanks
    -Leo

  3. leoahrens
    Member
    Posted 1 year ago #

    i deleted this part...

    <?php
    if ( has_post_thumbnail() ) { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=500&w=980&zc=1" alt=""/></a>
    <?php } else { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>

    and replaced it with...

    <?php
    if ( has_post_thumbnail() ) { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=500&w=980&zc=1" alt=""/></a>
    <?php } else { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>

    Seems to have worked! Let me know if this is not the proper method to make this work...

  4. leoahrens
    Member
    Posted 1 year ago #

    Err I mean I replace it with...
    <?php the_content('Read the rest of this entry &raquo;'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic