Wordpress custom work

Discussion in 'WordPress' started by kevbo22, Feb 21, 2011.

  1. #1
    I am customizing a theme for wordpress to match my current site. I am using starkers naked theme located here: http://starkerstheme.com/. I am wondering if someone can help me make the index page show the excerpt of all the posts instead of the content. I have edited both loop.php and index.php with no luck. Thanks.
     
    kevbo22, Feb 21, 2011 IP
  2. schwarzes

    schwarzes Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    instead of the_content();

    use the_excerpt();

    Hope this helps..
     
    schwarzes, Feb 21, 2011 IP
  3. kevbo22

    kevbo22 Active Member

    Messages:
    149
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    LOL, that seems to be a great solution for most themes. This naked theme I am using doesnt have that. Here is what is has:

    get_header(); ?>
    <div class="frontpage">

    <?php
    get_template_part( 'loop', 'index' );
    ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks for any help!
     
    kevbo22, Feb 21, 2011 IP
  4. schwarzes

    schwarzes Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I was going to give an answer to your question now as well, but seems like you have zero knowledge about Wordpress themes and instead of typing a "LOL" ask where it could be ? But you lost it.. ;)
     
    schwarzes, Feb 21, 2011 IP
  5. kevbo22

    kevbo22 Active Member

    Messages:
    149
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    I put lol because after all the searching and edits that I have done, it made me laugh (tried it in every loop and it isnt in index). It wasnt an insult, I do apologize. Thanks for your time, hopefully someone knows a quick answer.
     
    Last edited: Feb 21, 2011
    kevbo22, Feb 21, 2011 IP
  6. kevbo22

    kevbo22 Active Member

    Messages:
    149
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    So I got it working now. For any one who is creating a wordpress theme from scratch and are using the starkers "naked theme", here is what I did to make the home page show the excerpt instead of the entire article:

    <?php

    /* This is the new loop to display a featured story.
    * It creates a variable and then loads all the posts that match the query.
    */

    $my_query = new WP_Query('category_name=Featured Story&showposts=1');

    /* Now it loops through the results and displays the content.
    */

    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;

    /* We load the Page ID in to a variable to check for duplicates later on
    * Then it displays the title as a working link with formatting to
    * match the Twenty Ten template.
    * Then we display the excerpt.
    * Then we finish the loop with the endwhile statement
    */
    ?>

    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php the_excerpt();?>
    <?php endwhile; ?>

    <?php

    /* This is the second loop that replaces the standard loop
    * It uses the standard loop function calls
    */

    if (have_posts()) : while (have_posts()) : the_post();

    if( $post->ID == $do_not_duplicate ) continue;
    update_post_caches($posts);

    /* This line gets the post ID and checks it agains our duplicate variable
    * If it matches it does nothing. If it's different we display the content
    */

    ?>

    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
    <?php endwhile; endif; ?>

    <?php
    /* Run the loop to output the posts.
    * If you want to overload this in a child theme then include a file
    * called loop-index.php and that will be used instead.
    */
    //get_template_part( 'loop', 'index' );
    ?>

    You can add the posted on date, author, posted in etc if you want. Oh by the way I followed this tut http://www.andydickinson.net/2010/09/21/how-to-create-a-wordpress-magazine-theme-using-twentyten/
     
    kevbo22, Feb 21, 2011 IP