Grow your CSS skills. Land your dream job.

Posts on index.php are short by default

  • # March 13, 2010 at 3:49 pm

    I’m trying to make it so, by default, each post on index.php is 300px tall, including the meta data and post title (kind of like how it is on http://pexeto.com/sintagma_wp/?page_id=123).

    Is it possible to make every post default to only what text and images can fit in like a 200px high box, then include the "Continue reading…" button? I’m trying to make the index.php clean, like everything being the same height.

    # March 13, 2010 at 4:46 pm

    in your loop, instead of using

    Code:
    the_content()

    you can use

    Code:
    the_excerpt()

    (read about it here…http://codex.wordpress.org/Template_Tags/the_excerpt)

    by default it uses the first 55 words (omitting graphics and HTML tags…), but there is a field in the admin to specify your excerpt per post (right under the post text field.) this will allow you to use whatever you want as an excerpt….

    If using the first 55 words way, it just displays [...] at the end to indicate more, but you can customize this by adding the following to your theme’s functions.php file:

    Code:
    function new_excerpt_more($post) {
    return ‘ID) . ‘”>’ . ‘Read the Rest…’ . ‘‘;
    }
    add_filter(‘excerpt_more’, ‘new_excerpt_more’);

    If you make your own, you can just manually add a link at the end such as this… (lorem ipsum for the excerpt..)

    Code:
    Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Read the Rest…

    you would replace "http://yourdomain.com/yourpostpath" with the permalink of the post which you can copy from the line directly below the title field in the post editor…

    hope that makes sense.

    # March 13, 2010 at 5:34 pm

    Thanks! I’ve got the automatic excerpt going. I’d like to be able to still show the image for each post in the excerpt, the post thumbnail.

    I plan to have a 200×200 post thumbnail for every post, so I’d like each one displayed next to the excerpt of the post. I don’t know how to do it, but maybe it’s easier if I make two sections for each post, and in one I call the post thumbnail (somehow), and the other just calls the excerpt?

    # March 15, 2010 at 9:10 am

    well, if you are not using custom fields for your thumbnails, I would suggest it highly. It makes it very flexible when theming your site.

    In your case you could do something like add a custom field call "thumbnail-img" and then give it a value of the path to your thumbnail image (http://domain.com/wp-content/themes/the … /image.jpg)

    then in your theme file, after the_excerpt() add this code…

    Code:
    $thumbnailImg = get_post_meta($post->ID, “thumbnail-img”, true);

    if($thumbnailImg != “”)
    { echo ‘‘;}

    basically, this sets a variable and stores the path to the image, then if that path is not empty, you create an image tag, where it’s src attribute to the path name of the image… voila…

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".