• Hello everyone
    I was looking trought the forums and couldnt really find anything about my problem.

    Im currently using Arthemia Theme on my website https://www.mantratrain.net and my problem is with the previews of the posts.
    I cant define amount of the text that comes out on the main page beside each single thumbnail pic.

    As you can see, Im getting only one line of preview text beside each post. Im sure there’s a way of defining more of the preview that there is. Would anyone know how to set that up?

    Thanks in advance!
    W

Viewing 10 replies - 1 through 10 (of 10 total)
  • can you give your index.php file

    Thread Starter woyteac

    (@woyteac)

    <?php get_header(); ?>
    	<?php slidedeck( 4, array( 'width' => '100%', 'height' => '300px' ) ); ?>
    	<?php if(!is_paged()) { ?>
    
    	<div id="top" class="clearfloat">
    
    		<div id="headline">
    		<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/headline.png" width="75px" height="21px" alt="" />
    		<?php query_posts("showposts=1&category_name=Headline"); ?>
    		<?php while (have_posts()) : the_post(); ?>	
    
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>
    	<?php $values = get_post_custom_values("Headline");?>
     	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=300&h=275&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="300px" height="275px"  /></a>
    	<?php the_excerpt(); ?>
    	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read the full story &raquo;</a>
    	<?php endwhile; ?>
    		</div>
    
    	<div id="featured">
    
    	<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/featured.png" width="72px" height="17px" alt="" />
    
    	<?php query_posts("showposts=4&category_name=Featured"); $i = 1; ?>
    
          	<?php while (have_posts()) : the_post(); ?>
    	<div class="clearfloat">
    	<?php $values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=100&h=65&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="100px" height="65px"  /></a>
          <?php } ?>
    	<div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
    <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>	
    
    </div>
        	</div>
    
          <?php endwhile; ?>
    
    	</div>
    
    </div>	
    
    	<div id="middle" class="clearfloat">
    	<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" />
    	<?php $display_categories = array(75,1,4,14,107); $i = 1;
    	foreach ($display_categories as $category) { ?>
    
    	<div id="cat-<?php echo $i; ?>" class="category">
    		<?php query_posts("showposts=1&cat=$category")?>
    		<span class="cat_title"><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></span>
    		<a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a>
    	</div>
    
    	<?php $i++; ?>
        	<?php } ?>
    
    	</div>
    
    	<?php } ?>
    
    	<div id="bottom" class="clearfloat">
    
    	<div id="front-list">	
    
    	<?php
          $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
          query_posts("cat=-27,-28&paged=$page&posts_per_page=5"); ?>
    	<?php slidedeck( 2 ); ?>
    	<?php while (have_posts()) : the_post(); ?>		
    
    	<div class="clearfloat">
    	<h3 class=cat_title><?php the_category(', '); ?> &raquo</h3>
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>	
    
    	<div class="spoiler">
    	<?php	$values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="150px" height="150px"  /></a>
          <?php } ?>
    
    	<?php the_excerpt(); ?>
    	</div>
    
    	</div>
    
          <?php endwhile; ?>
    
    	<div class="navigation">
    		<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    			else { ?>
    
    			<div class="right"><?php next_posts_link('Next Page &raquo;') ?></div>
    			<div class="left"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    			<?php } ?>
    
    	</div>
    
    	</div>
    
    	<?php get_sidebar(); ?>
    
    	</div>	
    
    <?php get_footer(); ?>

    Try this :

    function entry_post($number) {
    	$content = get_the_content();
    	$content = apply_filters('the_content', $content);
    	$content = preg_replace('@<script[^>]*?>.*?</script>@si', '', $content);
    	$content = preg_replace('@<style[^>]*?>.*?</style>@si', '', $content);
    	$content = preg_replace('|<img.*?src=[\'"](.*?)[\'"].*?>|i', '', $content);
    	$content = strip_tags($content);
    	$content = substr($content, 0, strrpos(substr($content, 0, $number), ' '));
    	echo $content;
    	echo "...";
    }

    Write this code in your functions.php page and replace this code <?php the_excerpt() ?> with <?php entry_post(400) ?>

    Thread Starter woyteac

    (@woyteac)

    Thanks a million!
    I can see your point there, but cant really implement it (right)…
    would you insert this in the right spot for me plese ??

    Sorry, (its not being lazy)

    functions.php:

    <?php if ( function_exists('register_sidebar') )
    {
    register_sidebar(array('name' => 'Sidebar Top','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Sidebar Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Sidebar Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Sidebar Bottom','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Footer Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Footer Center','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    register_sidebar(array('name' => 'Footer Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>'));
    } 
    
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    function custom_trim_excerpt($text) { // Fakes an excerpt if needed
    global $post;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    
    		$text = strip_shortcodes( $text );
    
    		$text = apply_filters('the_content', $text);
    		$text = str_replace(']]>', ']]>', $text);
    		$text = strip_tags($text);
    		$excerpt_length = apply_filters('excerpt_length', 90);
    		$words = explode(' ', $text, $excerpt_length + 1);
    		if (count($words) > $excerpt_length) {
    			array_pop($words);
    			array_push($words, '...');
    			$text = implode(' ', $words);
    		}
    	}
    	return $text;
    }
    
    ?>

    index.php:

    <?php get_header(); ?>
    	<?php slidedeck( 4, array( 'width' => '100%', 'height' => '300px' ) ); ?>
    	<?php if(!is_paged()) { ?>
    
    	<div id="top" class="clearfloat">
    
    		<div id="headline">
    		<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/headline.png" width="75px" height="21px" alt="" />
    		<?php query_posts("showposts=1&category_name=Headline"); ?>
    		<?php while (have_posts()) : the_post(); ?>	
    
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>
    	<?php $values = get_post_custom_values("Headline");?>
     	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=300&h=275&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="300px" height="275px"  /></a>
    	<?php the_excerpt(); ?>
    	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read the full story &raquo;</a>
    	<?php endwhile; ?>
    		</div>
    
    	<div id="featured">
    
    	<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/featured.png" width="72px" height="17px" alt="" />
    
    	<?php query_posts("showposts=4&category_name=Featured"); $i = 1; ?>
    
          	<?php while (have_posts()) : the_post(); ?>
    	<div class="clearfloat">
    	<?php $values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=100&h=65&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="100px" height="65px"  /></a>
          <?php } ?>
    	<div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
    <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>	
    
    </div>
        	</div>
    
          <?php endwhile; ?>
    
    	</div>
    
    </div>	
    
    	<div id="middle" class="clearfloat">
    	<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/category.png" class="clearfloat" alt="" />
    	<?php $display_categories = array(75,1,4,14,107); $i = 1;
    	foreach ($display_categories as $category) { ?>
    
    	<div id="cat-<?php echo $i; ?>" class="category">
    		<?php query_posts("showposts=1&cat=$category")?>
    		<span class="cat_title"><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?></a></span>
    		<a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a>
    	</div>
    
    	<?php $i++; ?>
        	<?php } ?>
    
    	</div>
    
    	<?php } ?>
    
    	<div id="bottom" class="clearfloat">
    
    	<div id="front-list">	
    
    	<?php
          $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
          query_posts("cat=-27,-28&paged=$page&posts_per_page=5"); ?>
    	<?php slidedeck( 2 ); ?>
    	<?php while (have_posts()) : the_post(); ?>		
    
    	<div class="clearfloat">
    	<h3 class=cat_title><?php the_category(', '); ?> &raquo</h3>
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>	
    
    	<div class="spoiler">
    	<?php	$values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="150px" height="150px"  /></a>
          <?php } ?>
    
    	<?php the_excerpt(); ?>
    	</div>
    
    	</div>
    
          <?php endwhile; ?>
    
    	<div class="navigation">
    		<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    			else { ?>
    
    			<div class="right"><?php next_posts_link('Next Page &raquo;') ?></div>
    			<div class="left"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    			<?php } ?>
    
    	</div>
    
    	</div>
    
    	<?php get_sidebar(); ?>
    
    	</div>	
    
    <?php get_footer(); ?>

    Thread Starter woyteac

    (@woyteac)

    I think I might have made this after all! ??

    but not in all the sections of the main page.
    Would you have an idea how to apply this to all the excerpts ?
    so they display more of the preview text?

    thanks in advance!

    Moderator keesiemeijer

    (@keesiemeijer)

    Try this: https://codex.www.ads-software.com/Template_Tags/the_excerpt#Control_Excerpt_Length_using_Filters
    What I don’t get is why your excerpts are so small. Is there a settings page for your theme or do you have plugins that control the excerps lenght?

    Moderator keesiemeijer

    (@keesiemeijer)

    Aha. Your theme’s function.php removes the filter get_the_excerpt (twice just to be sure). And use your own custom_trim_excerpt function.

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');

    just delete this from functions.php

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    function custom_trim_excerpt($text) { // Fakes an excerpt if needed
    global $post;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    
    		$text = strip_shortcodes( $text );
    
    		$text = apply_filters('the_content', $text);
    		$text = str_replace(']]>', ']]>', $text);
    		$text = strip_tags($text);
    		$excerpt_length = apply_filters('excerpt_length', 90);
    		$words = explode(' ', $text, $excerpt_length + 1);
    		if (count($words) > $excerpt_length) {
    			array_pop($words);
    			array_push($words, '...');
    			$text = implode(' ', $words);
    		}
    	}
    	return $text;
    }

    and replace with this:

    function new_excerpt_length($length) {
    	return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    change 20 to the excerplength of your liking

    Thread Starter woyteac

    (@woyteac)

    I hate when WP takes so long to update changes…
    im clearing cache, changing browsers, but sometimes just got to be patient…
    Is there a way to go around it ?

    keesiemeijer – thanks! i will try that shortly!

    yes. you also used the keesiemeijer’s code. Hope it will solve your issue

    Hi Woyteac,

    Mind sharing how you placed the image below the navigation bar?

    Another question guys, how do we get excerpts to get displayed at Featured posts along with the title and thumbnail?

    Thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Problem with defining excerpts on the main page’ is closed to new replies.