• Resolved nickaster

    (@nickaster)


    HI there.

    I’m trying to change my category archives from “standard” blog style pages to a grid showing only headlines and excerpts.

    I have the following HTML/PHP in the original:

    <?php while (have_posts()) : the_post(); ?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    					<div class="meta">
    						<h5><span class="author"><?php echo get_avatar( get_the_author_email(), '18' );?> Posted by <?php the_author_link(); ?> <?php the_time('F jS, Y'); ?></span> <span class="commentNum"><a href="<?php comments_link(); ?>" title="Comments on <?php the_title_attribute(); ?>"><img src="<?php bloginfo('template_url');?>/images/comment.png" /></a> <a href="<?php comments_link(); ?>" title="Comments on <?php the_title_attribute(); ?>"><?php comments_number('0 Comments', '1 Comment', '% Comments', '');?></a></h5>
    					</div>
    					<div class="entry">
    						<?php the_content('',FALSE,''); ?>
    						<p class="more"><img src="<?php bloginfo('template_url');?>/images/page_white_text.png" /> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> Read Full Article &raquo;</a> <img src="<?php bloginfo('template_url');?>/images/usergroup2-vi.gif" /> <a href="#">Discuss This &raquo;</a></p>
    					</div>
    				</div>
    
    		<?php endwhile; ?>

    I can get rid of most of the extra stuff, no problem, but what part of that code controls the actual content? I’m guessing it’s <?php the_content('',FALSE,''); ?> right?

    What do I need to do to that PHP to make it just show X words of the article, minus any HTML or images?

    Thanks!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • it should work, if you exchange <?php the_content('',FALSE,''); ?> with <?php the_excerpt(); ?>

    https://codex.www.ads-software.com/Template_Tags/the_excerpt

    that will restrict the content to 55 words by default – no formatting, no images.

    you can set the number of words with some extra code – description in the linked docu.

    Thread Starter nickaster

    (@nickaster)

    Thanks! So… I can’t just specify the length of the excerpt in the code, I actually have to globally change it in functions.php?

    How do I control the number of posts that get spit out?

    Thread Starter nickaster

    (@nickaster)

    Nevermind… got it:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string .'&posts_per_page=20&paged=' . $paged);
    ?>

    Not that I have a clue how that works, but so it goes with the voodoo around here

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting images out of posts’ is closed to new replies.