Support » Themes and Templates » Show full length post when sticky and increase excerpt length

  • Resolved infopursuits

    (@infopursuits)


    I’m fairly new to WordPress and don’t know anything at all about coding. I have tried plug-ins and searching, hoping to avoid having to edit files, but it appears I am going to have no choice.

    The situation is this: I don’t like the super short excerpt lengths on posts, where the reader has to click on “read more” to read the rest of the post. I would like it to be twice this long, or 110 words, before it does this.

    I also want the option to show my first post, a “sticky” post on my posting page, in its full length. I don’t want it to be excerpted at all, as it is just an introductory post. Truthfully, if I could just fix the first problem, I wouldn’t have to worry about this, as my introductory post is short enough that it wouldn’t be exerpted.

    I have searched this forum and google, and tried installing plug-ins that are supposed to help customize excerpts. For some reason, my theme (Frontier) just ignores them. The relevant coding for this is not in the index.php file, but in a separate file called loop-blog.php. Maybe that is why the plug-ins don’t work?

    Honestly, if I can find a solution other than editing the code, I would be very happy. However, if I must edit the code, can someone please show me exactly what to take out and what to replace it with? Or what to add? No two answers to similar questions have revealed the same answer, and my code doesn’t match up perfectly with any of the examples I have been able to find. I have copied and pasted the code below.

    Thank you in advance for your assistance.

    <?php do_action('frontier_before_blog_post'); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class('blog-view'); ?>>
    
    <header class="entry-header">
    	<h2 class="entry-title"><a>"><?php echo the_title(); ?></a></h2>
    </header>
    
    <div class="entry-byline">
    	<?php $blog_elements = frontier_option('blog_elements'); ?>
    
    	<?php if ( !isset($blog_elements['author']) || $blog_elements['author'] != 0 ) : ?><div class="entry-author"><i class="genericon genericon-user"></i><?php the_author_posts_link(); ?></div><?php endif; ?>
    	<?php if ( !isset($blog_elements['published']) || $blog_elements['published'] != 0 ) : ?><div class="entry-date"><i class="genericon genericon-day"></i><a>"><?php the_time(get_option('date_format')); ?></a></div><?php endif; ?>
    	<?php if ( ( !isset($blog_elements['categories']) || $blog_elements['categories'] != 0 ) && ( get_post_type() == 'post' ) ) : ?><div class="entry-categories"><i class="genericon genericon-category"></i><?php the_category(', '); ?></div><?php endif; ?>
    	<?php if ( !isset($blog_elements['comment_info']) || $blog_elements['comment_info'] != 0 ) : ?><div class="entry-comment-info"><i class="genericon genericon-comment"></i><a>#comment-area"><?php comments_number( __('Comments', 'frontier'), __('1 Comment', 'frontier'), __('% Comments', 'frontier') ); ?></a></div><?php endif; ?>
    	<?php edit_post_link( __('Edit', 'frontier'), '<i class="genericon genericon-edit"></i>' ); ?>
    </div>
    
    <div class="entry-content">
    	<?php do_action('frontier_before_blog_post_content'); ?>
    
    	<?php if ( frontier_option('blog_display', 'excerpt') == 'excerpt' ) : ?>
    
    		<?php if ( has_post_thumbnail() && $blog_elements['thumbnail'] == 1 ) : ?>
    			<div class="entry-thumbnail">
    				<a>"><?php frontier_option('excerpt_thumbnail', '150') == '150' ? the_post_thumbnail('thumbnail') : the_post_thumbnail('thumb-200x120'); ?></a>
    			</div>
    		<?php endif ; ?>
    
    		<div class="entry-excerpt"><?php the_excerpt(); ?></div>
    
    	<?php else : ?>
    
    		<?php the_content(); ?>
    
    	<?php endif ; ?>
    
    	<?php wp_link_pages( array(
    		'before'           => '<div class="page-nav">' . __('<span>Pages</span>', 'frontier'),
    		'after'            => '</div>',
    		'link_before'      => '<span>',
    		'link_after'       => '</span>',
    		'next_or_number'   => 'number',
    		'nextpagelink'     => __('Next page', 'frontier'),
    		'previouspagelink' => __('Previous page', 'frontier'),
    		'pagelink'         => '%',
    		'echo'             => 1 )
    		);
    	?>
    	<?php do_action('frontier_after_blog_post_content'); ?>
    </div>
    
    <footer class="entry-footer">
    	<?php if ( frontier_option('blog_display', 'excerpt') == 'excerpt' ) : ?>
    		<div class="read-more"><a>" class="read-more-link"><?php _e('Continue Reading', 'frontier'); ?></a></div>
    	<?php else : ?>
    		<?php if ( $blog_elements['updated'] == 1 ) : ?><div class="entry-updated updated"><?php _e('Updated:', 'frontier'); ?> <?php the_modified_date(); ?> @ <?php the_modified_time(); ?></div><?php endif ; ?>
    		<?php if ( ($blog_elements['tags'] == 1) && ( get_post_type() == 'post' ) ) : ?><div class="entry-tags"><?php the_tags(); ?></div><?php endif ; ?>
    	<?php endif ; ?>
    </footer>
    
    </article>
    <?php do_action('frontier_after_blog_post'); ?>

    [Moderator Note: Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 8 replies - 1 through 8 (of 8 total)
  • esmi

    (@esmi)

    Forum Moderator

    Where did you download this theme from?

    I downloaded it through WordPress, when I clicked on themes, then chose the option to get new themes, it was on the list of themes. I love everything else about this theme, and I don’t think there is anything wrong with the theme. I believe it is perfectly legit. I just don’t know anything about coding.

    @infopursuits

    I have searched this forum and google, and tried installing plug-ins that are supposed to help customize excerpts. For some reason, my theme (Frontier) just ignores them.

    What plugins have you tried?

    Frontier Theme outputs excerpts using the WordPress function the_excerpt() If you want to modify that you must use a child-theme and add the code posted here http://ronangelo.com/topic/length-of-wordpress-excerpt/

    I also want the option to show my first post, a “sticky” post on my posting page, in its full length.

    Again, you have to be using a child-theme. Put this code on your child-theme’s functions.php

    function content_for_sticky($text) {
    	if ( is_sticky() ) {
    		$text = the_content();
    	}
    	return $text;
    }
    add_filter( 'the_excerpt', 'content_for_sticky' );

    And to hide the “Continue Reading” button for sticky posts, add this on Frontier Options -> CSS

    article.sticky .read-more-link {display: none;}

    Next time try to post on these link so that the handsome theme author is notified 🙂
    http://wordpress.org/support/theme/frontier

    Frontier Theme

    I take it the handsome theme author is you? I really like this theme–very professional-looking. You must think I’m a real moron now, but it only gets worse–I don’t know what a child theme is! Is it terribly complicated to add one?

    As far as plugins, I’ve tried advanced excerpt and fancy excerpt.

    Also, what if I want to just change the length of the excerpt from the default 55 words to 120? Can I use the code at the link you provided to do that without setting up a child theme, or do I still have to do that?

    And I apologize for not posting in the right place. I will be sure and do that next time. 🙂

    @infopursuits
    You can accomplish all the things stated above even without using a child theme. Just add the codes on frontier theme’s functions.php. But this would also mean that you might not be able to update the theme anymore because if you do, all the changes you’ve made will be lost.
    http://codex.wordpress.org/Child_Themes

    If you do decide to use a child-theme, one is already available here http://ronangelo.com/frontier/ You can just upload it like a normal theme then activate.

    Oh, thank you very much! I will definitely use the child theme. I just got done giving myself a little crash course in child themes! Your help is very much appreciated.

    I’ve installed the child theme and added the code you suggested to the functions page to make sticky posts full-length, plus I added the suggested code to the css file to hide the “read more” link. But now it is doing something weird: The phrase “read more” is replacing whatever word I end the post with. When I had a hyperlink there, it replaced the whole hyperlink.

    If I take the change in the css file, then I get this “read more” in place of my last word AND the “read more” link a couple lines down from the article.

    It looks to me like the “read more” is replacing the ellipses (…) that would have come at the end of the excerpt.

    Here’s the link: http://www.infopursuits.com/freearticles-2

    Thanks,
    Candace

    Nevermind, I see what caused the problem–I still had an excerpt plug-in enabled. Once I deactivated it, problem solved. Thank you very much for your help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show full length post when sticky and increase excerpt length’ is closed to new replies.