logo

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

Hello. Thanks for whomever is about to help me. On my blog... http://www.brandonandlisa.com/blog

Zip file to theme...

http://www.brandonandlisa.com/magazine_10.rar

post images located here
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!

page_blog.php
<?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(); ?>


home.php
<?php 

get_header();

function sp_read_more_from($position) {
?>
<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>
<?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(); ?>



archive.php

<?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(); ?>


funtions.php
<?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.

Brandon Boshnack | 02/11/10 at 1:26am | Edit


(4) Possible Answers Submitted...

  • avatar
    Last edited:
    02/11/10
    3:23am
    kjll kll says:

    First try this:

    search for

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


    replace it with

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



    Or try this quick possible solution:

    search for

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


    replace it with

    <?php the_content(''); ?>


    now you can use the tag <!--more--> when writing a post to split the "preview" from the rest of the article's text...

    In my opinion, this gives you a better control of the article preview, than cutting it of after 315 letters...

    just give it a try....

    • 02/11/10 12:24pm

      Brandon Boshnack says:

      Unfortunetely, I can't find the original

      <?php the_content_limit(315, ""); ?> 
      in page_blog.php to even try your suggestion. Am I looking in the wrong file? What should I do?

    • 02/11/10 12:31pm

      kjll kll says:

      Unfortunetely, I can't find the original

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

      in page_blog.php to even try your suggestion. Am I looking in the wrong file? What should I do?


      It's in home.php ... sorry...

    • 02/11/10 12:42pm

      Brandon Boshnack says:

      Sorry but after following your instructions - still a no go.

    • 02/11/10 1:03pm

      kjll kll says:

      Strange... I've tested the theme and everything is working fine... Is your wordpress version up to date?

    • 02/11/10 1:07pm

      kjll kll says:

      I might be, that the "tweet me" button you are using within you articles (or is it a plugin) is causing the problem... could you try writing down a plain posting?

    • 02/11/10 1:17pm

      Brandon Boshnack says:

      So I tried deactivating the "tweet me" button and went to blog and category and still no preview of the pic and post content.

      As you say you tested the theme and everything is working fine, what do you mean by that? I am not seeing any preview of content with the pic showing up on the blog and category pages.

    • 02/11/10 1:34pm

      kjll kll says:

      Have a look at your test posting:


      TEST A


      is written...

      Now, lets try something else:

      in home.php

      search for:


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



      Replace it with:

      <?php the_content(); ?>


      and use the more tag when writing a post to cut off the preview from the rest of the article


      Everything should do now... I tested it on my own wordpress installation and it works

    • 02/11/10 1:58pm

      Brandon Boshnack says:

      o.k. Thanks a bunch as we are now getting somewhere. So I followed your instructions and it worked. However two issues...

      1st. The more tag effected all the other posts and showed all the content.

      2nd. The link for #more is not the exact URL of the post and want them to be able to click on the link [continue reading] so there is no SEO issues.

      How can I have it where the content shows the first paragraph or so with pic and able to hit the [continue reading] link vs. #more.

      Last but not least, your instructions did not effect the category pages as I am looking to achieve the same thing.

      Anyways, thanks a lot for your help and guidance. We are headed in the right track:) Next step?

  • avatar
    Last edited:
    02/11/10
    3:50am
    Andrea Pernici says:

    Usually the_content_limit strip html tags, but can you explain better your problem ? You have a problem with image or with content ?

  • avatar
    Last edited:
    02/11/10
    3:56pm
    Ali Hussain says:

    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

    • 02/11/10 12:28pm

      Brandon Boshnack says:

      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(); ?>

    • 02/11/10 12:32pm

      Brandon Boshnack says:

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

      What do you mean by?

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


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

    • 02/11/10 12:41pm

      Ali Hussain says:

      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

      Attached Image

    • 02/11/10 12:48pm

      Brandon Boshnack says:

      http://www.brandonandlisa.com/magazine_10.rar

    • 02/11/10 1:19pm

      Ali Hussain says:

      I have attached the edited theme. Instructions for images:


      1. Upload an image
      2. Copy image link url (http://i48.tinypic.com/14kv3ad.jpg)
      3. Paste it in the custom field box, with the name "thumb" and value of the link url (http://i49.tinypic.com/kd96d0.jpg)
      4. Publish post it should work

    • 02/11/10 1:21pm

      Ali Hussain says:

      I have attached the edited theme. Instructions for images:


      1. Upload an image
      2. Copy image link url (http://i48.tinypic.com/14kv3ad.jpg)
      3. Paste it in the custom field box, with the name "thumb" and value of the link url (http://i49.tinypic.com/kd96d0.jpg)
      4. Publish post it should work

    • 02/11/10 1:22pm

      Ali Hussain says:

      I have attached the edited theme. Instructions for images:


      1. Upload an image
      2. Copy image link url (http://i48.tinypic.com/14kv3ad.jpg)
      3. Paste it in the custom field box, with the name "thumb" and value of the link url (http://i49.tinypic.com/kd96d0.jpg)
      4. Publish post it should work

    • 02/11/10 1:28pm

      Ali Hussain says:

      I have attached the edited theme. Instructions for images:


      1. Upload an image
      2. Copy image link url (http://i48.tinypic.com/14kv3ad.jpg)
      3. Paste it in the custom field box, with the name "thumb" and value of the link url (http://i49.tinypic.com/kd96d0.jpg)
      4. Publish post it should work

      Attached file (http://www.mediafire.com/file/mt3z22xy0wt/magazine_10_edited.rar)

    • 02/11/10 1:38pm

      Brandon Boshnack says:

      So I did the following as you can see on this image below for the post "virtual business"

      http://www.brandonandlisa.com/img/capture-1.gif

      And we are half way there!! Thanks a lot. Only issue now is that the preview text is not appearing within the post. So what now?

    • 02/11/10 1:46pm

      Brandon Boshnack says:

      So the pic is now showing up on the blog page via your instructions. However, the pic is not showing up on the category pages. How do I rectify that? Thanks. (just as important as blog post page's)

    • 02/11/10 1:57pm

      Ali Hussain says:

      What do you mean by "Only issue now is that the preview text is not appearing within the post."

      2. The category page works at my end, yet i have uploaded archive.php

    • 02/11/10 1:59pm

      Ali Hussain says:

      http://www.mediafire.com/file/0vvmc2hmmbw/archive.php

    • 02/11/10 2:05pm

      Brandon Boshnack says:

      "Only issue now is that the preview text is not appearing within the post."


      Picture is showing as you instructed for "blog" page but the content itself is not appearing.

      The category page works at my end

      If you go to the drop down box "free your mind" this is what I am seeing on the page..

      http://www.brandonandlisa.com/img/category.gif

    • 02/11/10 2:10pm

      Ali Hussain says:

      Works perfectly at my end, are you sure you replaced the archive.php which i just sent?

      May be login details would be better, would take me less time to work and more efficiency

    • 02/11/10 2:13pm

      Brandon Boshnack says:

      My apologies. Let me edit my previous message.

      The category pages is showing now!! Why? I updated your archive.php file. So... we are still having issues unfortunetely.

      If you go to "free your body" the pic is showing (right on!) but no content.
      If you go to "free yourself" the post "virtual business" is showing the content and pic! (thanks.) However, the next post "power of the internet" is not showing any content:(.

      We're getting there...

    • 02/11/10 2:21pm

      Ali Hussain says:

      My mistake, wrongly added the excerpt codes twice

      new archive file
      http://www.mediafire.com/file/emjwthmmtmz/archive.php

  • avatar
    Last edited:
    02/11/10
    12:33pm
    Tony Geer says:

    You can also trying searching for this:

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


    and replacing it with this:

    <?php the_excerpt(); ?>


    which is a built in Wordpress function that will by default display the first 55 words that are in your post. If you add text to the "Excerpt" textfield when you're writing a post, it will show that instead of the first 55 words. I'd recommend using this because it seems as though your code (the_content_limit) is causing a problem but the Wordpress code has been tested time and again and works perfectly fine.

    EDIT: You just posted the archives code, and in it it contains:

    <?php the_excerpt(); ?>


    Which is also what I recommended to make the fix on your homepage, so I don't think you'll have any issues with the archives page. So it should certainly work, let us know if it does.

    Previous versions of this answer: 02/11/10 at 12:33pm

    • 02/11/10 12:36pm

      Brandon Boshnack says:

      So tried putting some content into an excerpt and it didn't work at all. Also, there is no code of

      <?php the_content_limit(315, ""); ?>
      within page_blog.php that allowed me to replace it with
      <?php the_excerpt(); ?>
      .

      What is the next step?

This question has expired.





Current status of this question: Completed