WordPress.org

Ready to get started?Download WordPress

Forums

excerpt stuff? (19 posts)

  1. alexrogahn
    Member
    Posted 5 years ago #

    Is there a way I can make a post on the front page display an excerpt if I enter one but not if I don't and not limit the post to 55 characters. also I'd like a read more image to show on a post with an excerpt. I know about the <!--more--> tag and it doesn't do exactly what I want.

    Edit: and yes I have looked at codex :)

  2. moshu
    Member
    Posted 5 years ago #

    Maybe you need some excerpt related plugin(s). Take a look and search the Extend > Plugins section.

  3. alexrogahn
    Member
    Posted 5 years ago #

    looked already I don't see any that will do what I want

  4. moshu
    Member
    Posted 5 years ago #

  5. alexrogahn
    Member
    Posted 5 years ago #

    nope I don't even get what its suppose to do all I want is for a summary to be on the front page for long posts and a read on link. I don't want to use the "more" tag because it shows your teaser / summary in the actual post but the excerpt doesn't

  6. alexrogahn
    Member
    Posted 5 years ago #

    in fact it just broke my blog and made me have to remove it nice plugin >:(

  7. michael
    Member
    Posted 5 years ago #

    the excerpt question i can't answer. but the read more image:
    <a href="<php the_permalink()?>" ><img src="path of your read more image file"/></a>

  8. alexrogahn
    Member
    Posted 5 years ago #

    I know how to do that, sigh I created this
    <?php if (!empty($post->post_excerpt)) {the_excerpt(); } else { the_content(); } ?> 
    statement but it doesn't work it gives me this error
    Parse error: syntax error, unexpected T_STRING in domains/alexrogahn.com/html/wp-content/themes/AlexRogahnTheme/index.php on line 25

  9. alexrogahn
    Member
    Posted 5 years ago #

    managed to make it work

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt();
     } else {
         the_content();
     } ?>

    but I only want the read on link when it displays the excerpt once I have that I'm all finished ^.^

  10. moshu
    Member
    Posted 5 years ago #

    Then use the code given to you by mks6804 after the_excerpt

  11. alexrogahn
    Member
    Posted 5 years ago #

    nope it doesn't show up, hmmm this is what I've got

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt('<a href="<?php get_permalink() ?>">TEST</a>');
     } else {
         the_content();
     } ?>

    It won't work am I doing something wrong?

  12. moshu
    Member
    Posted 5 years ago #

    Yes. It is not a parameter of the_excerpt. It should be AFTER the template tag.

  13. alexrogahn
    Member
    Posted 5 years ago #

    I tried it like this first:

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt(); <a href="<?php get_permalink() ?>">TEST</a>
     } else {
         the_content();
     } ?>

    it gave me this error

    Parse error: syntax error, unexpected '<' in /domains/alexrogahn.com/html/wp-content/themes/AlexRogahnTheme/index.php on line 26

    then I tried it like this

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt()<a href="<?php get_permalink() ?>">TEST</a>;
     } else {
         the_content();
     } ?>

    and It gave me this:

    Parse error: syntax error, unexpected T_STRING in /domains/alexrogahn.com/html/wp-content/themes/AlexRogahnTheme/index.php on line 26

    a little help plz?

  14. moshu
    Member
    Posted 5 years ago #

    Because you need to close the PHP before starting HTML code or need to echo.
    I am not a coder, so never trust the code I write:

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt();
    echo "<a href="<?php get_permalink() ?>">TEST</a>";
     } else {
         the_content();
     } ?>

    (or something like this)

    On the other hand, with a little bit of search you could have find this, too:
    http://www.cameraontheroad.com/?p=732

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Fixed:

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt(); ?>
    <a href="<?php get_permalink() ?>">TEST</a>
    <?php
     } else {
         the_content();
     } ?>
  16. alexrogahn
    Member
    Posted 5 years ago #

    lol thanks, but this is the code that did what I wanted without any errors or loss of function

    <?php if(!empty($post->post_excerpt)) {
         the_excerpt();
    echo '<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>Read the rest of this article &raquo;</a>';
     } else {
         the_content();
    echo '<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>Goto Post Page &raquo;</a>';
     } ?>

    hope this helps anyone wanting the same as me to :)

  17. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Actually, that should not work. You've got the opening PHP happening twice without closing. Makes little sense to do <?php whatever ?> inside an echo statement.

  18. CD30
    Member
    Posted 5 years ago #

    Using everything said here, this is what I did:

    <?php if(!empty($post->post_excerpt))
       {the_excerpt(); ?><div class="more"> <a href="<?php the_permalink() ?>" rel="bookmark" class="title">(more...)</a> </div>
       <?php
       } else {
       the_content();
      } ?>

    ------

    css
    .more{
    padding-right:20px;
    text-align:right;
    }

    ---------

    If the excerpt is blank, it displays the whole post. Otherwise display the excerpt and add "more". And you can still use the "more" tag in the edit window to cut the text anywhere you want.
    ---------------

    Please let me know if you see any problem I'm not seeing.
    Thank you.

  19. slacklineradio
    Member
    Posted 5 years ago #

    I am looking for some support on how to insert php coding into the excerpt in the admin. I would like to call for the php the title and date so I can insert it under an image in the excerpt instead of it showing up above. I don't want to manually code it but would rather use php the_permalink. I can alter the loop to get rid of it showing up in front of the excerpt, but if I want to insert it somewhere in the_excerpt, it does not like php coding in the admin. Advice?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.