Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Excerpts, Read more, Pagination (http://forum.bytesforall.com/forumdisplay.php?f=20)
-   -   [SOLVED] Display Post Excerpts in Grid for Author, Search & Category (http://forum.bytesforall.com/showthread.php?t=5018)

Rashell Dec 27, 2009 01:19 PM

[SOLVED] Display Post Excerpts in Grid for Author, Search & Category
 
any ideas of how to do this?

I'm using ATA 3.4.4 WP2.9

My excerpts are just thumbnails. No descriptions or text.

I'd love to style them horizontally in 3-5 columns rather than the typical vertical in one column.

Rashell

Rashell Feb 13, 2010 03:47 PM

Finally I figured it out... and it wasn't hard at all. Just needed to step back so I could see the trees. Anywho...

To create a grid layout for archives, categories, tags, & author pages

1. create a new template page called archive.php to upload to your theme directory
2. insert this code into the template

PHP Code:

<?php
/*
Template Name: Archives
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<?php /* if index.php or another page template (copied from index.php) was not used
(i.e. by a plugin such as WPG2), the global $bfa_ata would be empty */
global $bfa_ata; if ($bfa_ata == "") include_once (TEMPLATEPATH '/functions/bfa_get_options.php'); ?>
<?php 
if ( $bfa_ata['css_external'] == "External" ) { ?>
<link rel="stylesheet" href="<?php echo $bfa_ata['get_option_home']; ?>/?bfa_ata_file=css" type="text/css" media="all" />
<?php ?>
<?php 
include (TEMPLATEPATH '/functions/bfa_meta_tags.php'); ?>
<?php 
if ($bfa_ata['favicon_file'] != "") { ?><link rel="shortcut icon" href="<?php echo $bfa_ata['template_directory']; ?>/images/favicon/<?php echo $bfa_ata['favicon_file']; ?>" /><?php ?>
<?php 
if ( is_single() OR is_page() ) { ?><link rel="canonical" href="<?php the_permalink(); ?>" /><?php ?>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php     wp_enqueue_script'jquery' ); ?>
<?php 
if ( function_exists('wp_list_comments') AND is_singular() ) {     wp_enqueue_script'comment-reply' ); } ?>
<?php wp_head
(); ?>
<?php 
echo ($bfa_ata['html_inserts_header'] != "" apply_filters(widget_text$bfa_ata['html_inserts_header']) : ''); ?>
<?php 
if ($bfa_ata['pngfix_selectors'] != "") { ?>
<!--[if IE 6]>
<script type="text/javascript" src="<?php echo $bfa_ata['template_directory']; ?>/js/DD_roundies.js"></script>
<script type="text/javascript">DD_roundies.addRule('<?php echo $bfa_ata['pngfix_selectors']; ?>');</script>
<![endif]-->
<?php ?>
</head>

<body <?php body_class(); ?><?php echo ($bfa_ata['html_inserts_body_tag'] != "" ' ' apply_filters(widget_text$bfa_ata['html_inserts_body_tag']) : ''); ?>><?php if(function_exists(updateHeader)) updateHeader(); ?>

<?php echo ($bfa_ata['html_inserts_body_top'] != "" apply_filters(widget_text$bfa_ata['html_inserts_body_top']) : ''); ?>


<div id="wrapper">
<div id="container">
<table id="layout" border="0" cellspacing="0" cellpadding="0">
<colgroup>
<?php if ( $bfa_ata['left_col'] == "on" ) { ?><col class="colone" /><?php ?>
<?php 
if ( $bfa_ata['left_col2'] == "on" ) { ?><col class="colone-inner" /><?php ?>
<col class="coltwo" />
<?php if ( $bfa_ata['right_col2'] == "on" ) { ?><col class="colthree-inner" /><?php ?>
<?php 
if ( $bfa_ata['right_col'] == "on" ) { ?><col class="colthree" /><?php ?>
</colgroup> 


    <tr>

        <!-- Header -->
        <td id="header" colspan="<?php echo $bfa_ata['cols']; ?>">
        <?php bfa_header_config($bfa_ata['configure_header']); ?>               
        </td>
        <!-- / Header -->

    </tr>

    <!-- Main Body -->    
    <tr id="bodyrow">

        <?php if ( $bfa_ata['left_col'] == "on" ) { ?>
        <!-- Left Sidebar -->
        <td id="left">

            <?php // Widgetize the Left Sidebar 
            
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Left Sidebar') ) : ?>
        
                    <div class="widget widget_categories"><div class="widget-title">
                    <h3><?php _e('Categories','atahualpa'); ?></h3>
                    </div>
                    <ul><?php wp_list_categories('show_count=1&title_li='); ?></ul>
                    </div>
                    
                    <div class="widget widget_archive"><div class="widget-title">
                    <h3><?php _e('Archives','atahualpa'); ?></h3>
                    </div>
                    <ul><?php wp_get_archives('type=monthly'); ?></ul>
                    </div>
                                    
            <?php endif; ?>

        </td>

        <!-- / Left Sidebar -->
        <?php ?>

        <?php if ( $bfa_ata['left_col2'] == "on" ) { ?>
        <!-- Left INNER Sidebar -->
        <td id="left-inner">

            <?php // Widgetize the Left Inner Sidebar 
            
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Left Inner Sidebar') ) : ?>
        
                    <!-- no default content for the LEFT INNER sidebar -->
                                    
            <?php endif; ?>

        </td>
        <!-- / Left INNER Sidebar -->
            <?php ?>

        <!-- Main Column -->
        <td id="middle">


<?php
 
//Code automatically inserted by Featurific for Wordpress plugin
 
if(is_home())                             //If we're generating the home page (remove this line to make Featurific appear on all pages)...
  
if(function_exists('insert_featurific')) //If the Featurific plugin is activated...
   
insert_featurific();                    //Insert the HTML code to embed Featurific
?>
<?php 
/* If there are any posts: */
if (have_posts()) : $bfa_ata['postcount'] == 0/* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

    <?php /* This outputs the next/previous post or page navigation. 
    This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
    
bfa_center_content($bfa_ata['content_above_loop']); ?>

<div id="container_division">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="post-block">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/>
<div class="excerpt-cats"><?php the_excerpt(); ?></div>
</div>

<?php endwhile; else: ?>
<?php 
endif; ?>
</div>

    <?php /* This outputs the next/previous post or page navigation and the comment template.
    This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
    
bfa_center_content($bfa_ata['content_below_loop']); ?>

<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.
This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
bfa_center_content($bfa_ata['content_not_found']); ?>

<?php endif; /* END of: If there are no posts */ ?>

<?php bfa_center_content($bfa_ata['center_content_bottom']); ?>

<?php get_footer(); ?>

3. Upload the file &
4. Then tweak your CSS Inserts to control your layout...

Code:

.post-block {float: left;}
.excerpt-cats {font-size: 1em;}

.post-block controls the post excerpt as an entire section in relation to the other post excerpts
you can also use it to style the font of the title of your post
.excerpt-cats styles the positioning of the text of the excerpt
.tfe controls the positioning of the thumbnail if you use the "thumbnails for excerpts" plugin

It's the small section below (found within the archive.php file starting on line 124) that controls what appears in the excerpts & in what order (you can change it if you like). I have it set up to display the post title & the excerpt. If you use the plugin "thumbnails for excerpts" your image thumbnail will be included automatically .

PHP Code:

<div id="container_division">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="post-block">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/>
<div class="excerpt-cats"><?php the_excerpt(); ?></div>
</div>

<?php endwhile; else: ?>
<?php 
endif; ?>
</div>

Example at: NanasCrafts.com

Rashell Apr 9, 2010 09:29 AM

Just an FYI,

From the time I'd written this post to now 4/2010 I've noticed that instead of creating a whole template with the header included you can actually just use the "get header command". You still want to create a new template as a .php file but all that you'd need to add to it is something similar to...

Code:

<?php
/*
Template Name: Archives
*/
?>

<?php        /* get all options: */
include (TEMPLATEPATH . '/functions/bfa_get_options.php');
get_header(); ?>

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata['postcount'] == 0; /* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

        <?php /* This outputs the next/previous post or page navigation.
        This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
        bfa_center_content($bfa_ata['content_above_loop']); ?>


<div class="post-block">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/>
<div class="excerpt-cats"><?php the_excerpt(); ?></div>
</div>

<?php endwhile; else: ?>
<?php endif; ?>
</div>

        <?php /* This outputs the next/previous post or page navigation and the comment template.
        This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
        bfa_center_content($bfa_ata['content_below_loop']); ?>

<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.  This can be edited at Atahualpa Theme Options -> Style & edit the Center column */ bfa_center_content($bfa_ata['content_not_found']); ?>

<?php endif; /* END of: If there are no posts */ ?>

<?php bfa_center_content($bfa_ata['center_content_bottom']); ?>

<?php get_footer(); ?>

So it looks more like the original index.php page.

Rashell

Ooops, I'd missed adding a snippet of code (which is now included). Thanks so much, nickmoreton, for pointing that out & adding the fix!


All times are GMT -6. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.