1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

wordpress coders

Discussion in 'Blogging' started by Nauthiz666, Mar 24, 2009.

  1. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    Can anyone give me a code i can insert into my single.php to make the full posts a excerpt as well? One that i could define in length parameter. Can't quite figure this out. (perferably without stripping images or anything else)
     
    Last edited: Mar 24, 2009
  2. zielak

    zielak Registered Member

    Joined:
    Jan 13, 2009
    Messages:
    77
    Likes Received:
    30
    Try this:
    - Install Advanced Excerpt Plugin

    In single.php replace
    Code:
    the_content('');
    with (replace xx with number of words):
    Code:
    the_advanced_excerpt('length=xx&use_words=1');
     
  3. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    awesome i will give this a try
     
  4. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    so where it says <?php the_content('Read more »'); ?>

    replace it to <?php the_advanced_excerpt('length=xx&use_words=1'); ?>

    ???

    i replaced xx to50, but all it did was wipe out all the words.
     
    Last edited: Mar 24, 2009
  5. zielak

    zielak Registered Member

    Joined:
    Jan 13, 2009
    Messages:
    77
    Likes Received:
    30
    Yes, replace it with:
    Code:
    <?php the_advanced_excerpt('length=xx&use_words=1'); ?>
    But change length=xx to number of words you want to have exp. length=40

    That's strange, I'm using it like this and it's working fine.
     
    Last edited: Mar 24, 2009
  6. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    hmm maybe im doing something wrong because its still just removing all the text together. Here is my source


    <?php get_header(); ?>

    <div id="content">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div class="post" id="post-<?php the_ID(); ?>">

    <div class="posthead">
    <h2><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <small class="postauthor">Posted on <?php the_time('M d, Y') ?> under <?php the_category(', ') ?> | <?php comments_popup_link(__('No Comment'), __('1 Comment'), __('% Comments'), 'commentslink', __('Comments are off')); ?> <?php edit_post_link(__('Edit'), ' · ', ''); ?></small>
    </div> <!-- end posthead -->

    <?php the_advanced_excerpt('length=xx&use_words=1'); ?>


    <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

    </div> <!-- end post -->






    strangely enough it works on index.php but not single.php
     
    Last edited: Mar 24, 2009
  7. zielak

    zielak Registered Member

    Joined:
    Jan 13, 2009
    Messages:
    77
    Likes Received:
    30
    In this code you still have length=xx, did you installed and activated Advanced Excerpt plugin ?
     
  8. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    yeah it is working too. I tried doing the same code change on index.php and it worked, but when i did it on single.php it just wiped out the content. plus the length i adjusted to is 50.
     
    Last edited: Mar 24, 2009
  9. zielak

    zielak Registered Member

    Joined:
    Jan 13, 2009
    Messages:
    77
    Likes Received:
    30
    Can you PM url of your site ?
     
  10. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    yeah sure hold on
     
  11. sodacrates

    sodacrates Registered Member

    Joined:
    Jan 13, 2009
    Messages:
    66
    Likes Received:
    4
    in index.php and single.php you can just replace
    Code:
    <?php the_content('Read more »'); ?>
    with

    Code:
    <?php the_excerpt('Read more »'); ?>
    without installing any pluggins
     
  12. spankythepyro

    spankythepyro Power Member

    Joined:
    Mar 7, 2009
    Messages:
    572
    Likes Received:
    94
    Question: I'm trying to get this to work with another plugin... however when using <?php content('# of words to show'); ?> it messes up my theme because of the image I guess... I can only use excerpt without it messing up the theme, even default theme.

    Does this plugin allow me to post an image and a certain # of words from content and link to the whole article without messing up the template? I don't have time atm because of exams to test this out! Thanks!
     
  13. Nauthiz666

    Nauthiz666 Senior Member

    Joined:
    Nov 14, 2008
    Messages:
    851
    Likes Received:
    80
    bump, i still cannot get single.php to be an excerpt also, ive tried new themes etc. Can anyone tell me how i can make my regular single.php posts also a slightly longer excerpt. Nevermind i got it, looks like it did have to do with the theme
     
    Last edited: Mar 25, 2009