Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Preview of posts not showing on blog and category page's WordPress

  • SOLVED

Hello. Thanks for whomever is about to help me. On my blog... http://www.brandonandlisa.com/blog
<strong>
Zip file to theme... </strong>
http://www.brandonandlisa.com/magazine_10.rar

<strong>post images located here</strong>
http://www.brandonandlisa.com/img/


The posts are not showing any preview where I need the picture along with the first 3-5 sentences to appear on both the blog & category pages. I tried messing around with the PHP coding and unfortunately having no success. Below are some codes that might help you help me. If you need any more info, please let me know! Thanks again and very grateful for this site!

<strong>page_blog.php</strong>
<?php
/*
Template Name: Blog
*/
?>

<?php get_header(); ?>

<div id="content">

<div id="contentleft">

<div class="postarea">


<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=".get_theme_mod('blog_cat')."&showposts=".get_theme_mod('blog_cat_num')."&paged=$page"); while ( have_posts() ) : the_post() ?>


<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

<?php require(TEMPLATEPATH . '/includes/post-author-block.php'); ?>

<?php the_content('[Read More..]'); ?>

<div class="clear"></div>

<?php require(TEMPLATEPATH . '/includes/post-meta-block.php'); ?>

<?php endwhile; ?>

<?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>

</div>

</div>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>


<strong>home.php</strong>
<?php

get_header();

function sp_read_more_from($position) {
?>
<strong><a href="<?php echo get_category_link(get_theme_mod($position)); ?>" rel="bookmark"><?php _e("Read More Posts From", 'studiopress'); echo " ". cat_id_to_name(get_theme_mod($position)); ?> &raquo;</a></strong>
<?php
}

function sp_post_thumb($post, $position) {
if( get_post_meta($post->ID, "thumb", true) ):
?>
<a href="<?php the_permalink() ?>" rel="bookmark">
<img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&amp;h=<?php echo get_theme_mod($position.'_thumb_height'); ?>&amp;w=<?php echo get_theme_mod($position.'_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" />
</a>
<?php
else:
// You might want to show a default image?
endif;
}
?>

<div id="content">

<div id="contentleft">

<?php if(get_theme_mod('tabber') == 'Yes') { ?>

<div class="hptabber">
<?php include(TEMPLATEPATH."/tabber.php");?>
</div>

<?php } else { ?>
<?php } ?>




<div class="hpfeatured">



<?php $recent = new WP_Query("showposts=6"); while($recent->have_posts()) : $recent->the_post();?>

<?php sp_post_thumb($post, 'featured_main'); ?>

<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>


<?php the_content_limit(315, ""); ?>

<a href="<?php the_permalink() ?>">[Continue Reading]</a>

<hr/>

<?php endwhile; ?>



</div>





<div class="clear"></div>

</div>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>



<strong>archive.php</strong>

<?php get_header(); ?>

<div id="content">

<div id="contentleft">

<div class="postarea">



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

<div <?php post_class(); ?>>

<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

<?php require(TEMPLATEPATH . '/includes/post-author-block.php'); ?>

<?php the_excerpt(); ?>

<div class="clear"></div>

<?php require(TEMPLATEPATH . '/includes/post-meta-block.php'); ?>

</div>

<?php endwhile; else: ?>

<?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>

<?php endif; ?>

<?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>

</div>

</div>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>


<strong>funtions.php</strong>
<?php

// Uncomment this to test your localization, make sure to enter the right language code.
// function test_localization( $locale ) {
// return "nl_NL";
// }
// add_filter('locale','test_localization');

load_theme_textdomain('studiopress', TEMPLATEPATH.'/languages/');

add_filter('comments_template', 'legacy_comments');

function legacy_comments($file) {

if(!function_exists('wp_list_comments')) : // WP 2.7-only check
$file = TEMPLATEPATH . '/legacy.comments.php';
endif;

return $file;
}

// Turn a category ID to a Name
function cat_id_to_name($id) {
foreach((array)(get_categories()) as $category) {
if ($id == $category->cat_ID) { return $category->cat_name; break; }
}
}

// Load the scripts
if(get_theme_mod('subnav') == 'Yes') {
wp_enqueue_script('subnav', get_bloginfo('template_url').'/js/subnav.js','','1.0',true);
} else {
wp_enqueue_script('nav', get_bloginfo('template_url').'/js/nav.js','','1.0',true);
}
if(get_theme_mod('tabber') == 'Yes') {
wp_enqueue_script('tabber', get_bloginfo('template_url').'/js/tabber.js','','1.0',true);
}

// include the breadcrumb nav tool
include(TEMPLATEPATH."/tools/breadcrumbs.php");

// include the theme options
include(TEMPLATEPATH."/tools/theme-options.php");

if ( function_exists('register_sidebars') )
register_sidebar(array('name'=>'Sidebar Right','before_title'=>'<h4>','after_title'=>'</h4>'));

function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
$content = strip_tags($content);

if (strlen($_GET['p']) > 0) {
echo "<p>";
echo $content;
if ($more_link_text != '') {
echo "&nbsp;<a rel='nofollow' href='";
the_permalink();
echo "'>".__('Read More', 'studiopress')." &rarr;</a>";
}
echo "</p>";
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "<p>";
echo $content;
echo "...";
if ($more_link_text != '') {
echo "&nbsp;<a rel='nofollow' href='";
the_permalink();
echo "'>".$more_link_text."</a>";
}
echo "</p>";
}
else {
echo "<p>";
echo $content;
if ($more_link_text != '') {
echo "&nbsp;<a rel='nofollow' href='";
the_permalink();
echo "'>".__('Read More', 'studiopress')." &rarr;</a>";
}
echo "</p>";
}
}

function sp_widget() {
require_once(ABSPATH.WPINC.'/rss.php');
if ( $rss = fetch_rss( 'http://feeds2.feedburner.com/studiopress' ) ) {
$content = '<div class="rss-widget>"';
$content .= '<p style="border-bottom: 1px solid #ccc; padding-bottom: 10px; font-weight: bold;"><a rel="nofollow" href="http://www.studiopress.com/themes/pro-plus">Upgrade now to the Pro Plus All-Theme package for only $140 --></a <br /> <small>(Use PPUPG as the discount code when you are on the shopping cart page.)</small></p>';
$content .= '<ul>';
foreach ( array_slice( $rss->items, 0, 5 ) as $item ) {
$content .= '<li>';
$content .= '<a class="rsswidget" href="'.esc_url( $item['link'] ).'">'.htmlentities( $item['title'] ).'</a>';
$content .= ' <span class="rss-date">'.date('F j, Y',strtotime($item['published'])).'</span>';
$content .= '<div class="rssSummary">'.htmlentities( $item['summary'] ).'</div>';
$content .= '</li>';
}
$content .= '</ul>';
$content .= '<p style="border-top: 1px solid #ccc; padding-top: 10px; font-weight: bold;"><a target="_blank" href="http://feeds2.feedburner.com/studiopress"><img style="vertical-align:middle;margin:0px 3px 3px 0px;" src="http://www.studiopress.com/images/rss.png" alt="Subscribe to StudioPress" /></a><a target="_blank" href="http://feeds2.feedburner.com/studiopress">Subscribe to RSS</a><a target="_blank" href="http://feedburner.google.com/fb/a/mailverify?uri=studiopress"></a>&nbsp;&nbsp;<img style="vertical-align:middle;margin:0px 3px 3px 0px;" src="http://www.studiopress.com/images/rss.png" alt="Subscribe to StudioPress" /></a><a target="_blank" href="http://feedburner.google.com/fb/a/mailverify?uri=studiopress">Subscribe via Email</a></p>';
$content .= '</div>';
echo $content;
}
}

function sp_widget_setup() {
wp_add_dashboard_widget( 'sp_db_widget' , 'The Latest News From StudioPress' , 'sp_widget');
}

add_action('wp_dashboard_setup', 'sp_widget_setup');

// Remove WP Generator for security reasons
remove_action('wp_head', 'wp_generator');
?>


Well I could keep posting all my codes but don't want to clutter the post. Let me know if there are any other codes I could post.

Answers (4)

2010-02-11

Ali Hussain answers:

Add

<img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&amp;h=<?php echo get_theme_mod($position.'_thumb_height'); ?>&amp;w=<?php echo get_theme_mod($position.'_thumb_width'); ?>&amp;zc=1" alt="<?php the_title(); ?>" />

<br />

<?php the_excerpt();?>


on the blog_page.php replacing

<?php the_content('[Read More..]'); ?>

Also make sure that you upload your images and add it in the post meta with the keyword thumb.

Also if possible, please share with your archive.php so it could be edited to show text on category pages


Brandon Boshnack comments:

here is the archive file... trying your instructions now...

<?php get_header(); ?>

<div id="content">

<div id="contentleft">

<div class="postarea">



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

<div <?php post_class(); ?>>

<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

<?php require(TEMPLATEPATH . '/includes/post-author-block.php'); ?>

<?php the_excerpt(); ?>

<div class="clear"></div>

<?php require(TEMPLATEPATH . '/includes/post-meta-block.php'); ?>

</div>

<?php endwhile; else: ?>

<?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>

<?php endif; ?>

<?php require(TEMPLATEPATH . '/includes/post-nav-block.php'); ?>

</div>

</div>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>


Brandon Boshnack comments:

unfortunetely, I have tried replacing the code as you instructed and nothing happened.

What do you mean by?
<blockquote>Also make sure that you upload your images and add it in the post meta with the keyword thumb.</blockquote>

Didn't do that if that was needed for everything to work..


Ali Hussain comments:

I meant adding a link to the direct image. Attached a screen-shot whereby you have to add the link. If still the problem exists, can be resolved in a few minutes if you could upload your theme in a zip file and share it with me