WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cannot adjust the excerpt length even with plugin or code (9 posts)

  1. Anchalee
    Member
    Posted 1 year ago #

    I'm really new with wordpress and have no knowledge about the code. That's why I need help here.

    Please let me give you my details first:
    wordpress version: 3.4.1
    theme: AdStyle, author: Gordon French, (provided on wordpress dashboard)

    My site was hacked on January and I lost everything as I did not have any backup. I need to re-build the new site, this time I really be careful with every step I work with the site.

    I follow all suggestion about the security and that include how to choose theme and plugin. I use AdStyle as it provided on wordpress dashboard, but unfortunately, it does not much flexible.

    I try not to use too many plugin and the suggestion says I should adjust on the code instead of too many plugin on my site.

    MY PROBLEM AND QUESTION:

    I would need to change the excerpt on the homepage, but I cannot do even with any plugin or adding the code I've searched.

    Now my theme provides:
    - very short excerpt on homepage
    - excerpt has no read more.... text
    - excerpt has no link to the full post
    - excerpt has no thumbnail

    What I need:
    - custome the excerpt length
    - add read more... text
    - make read more...text link to the full post
    - the thumbnail shows with the excerpt, thumbnail from the featured image of that post

    Some help from someone would be a big help to me.

    Can you please review the theme AdStyle (author: Gordon French, from wordpress theme choice) and suggest me what code to add to what file and the location to add the code.

    A big thank you in advance and really hope to hear from someone very soon.

    Thanks,
    Anchalee

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    edit index.php; find:

    <?php $truncateContent = truncate::doTruncate(strip_tags(get_the_content(), '<p><a><br/>'), 300, '.', '...'); ?>
                 <p class="desc"><?php echo $truncateContent; ?></p>

    - custome the excerpt length

    the length is determined by the number 300 - increase that.

    - add read more... text
    - make read more...text link to the full post

    for example, change the posted code section to:

    <?php the_post_thumbnail(); ?>
                 <?php $truncateContent = truncate::doTruncate(strip_tags(get_the_content(), '<p><a><br/>'), 300, '.', '...'); ?>
                 <p class="desc"><?php echo $truncateContent; ?></p>
                 <p class="readmore"><a href="<?php the_permalink(); ?>">read more ...</a></p>

    - the thumbnail shows with the excerpt, thumbnail from the featured image of that post

    the code for the thumbnail output is already in the above.
    you might also need to add some code to functions.php; see http://codex.wordpress.org/Post_Thumbnails

    will possibly need additional formatting - please post a link to your site for suggestions; or use a tool such as Firebug http://getfirebug.com/ to investigate what you need to edit.

  3. Anchalee
    Member
    Posted 1 year ago #

    Thanks a lot, alchymyth

    I've tried to add your suggested code. However, I have some more questions as below.

    My site: http://www.buddhabucha.net

    - It seems like only the first post on homepage that the excerpt length change as my revision (600), the rest post are the same.

    - The thumbnail does not show, it shows only the image name. (the first word on the first sentence of the first post is my image name)

    - I would like the read more text (อ่านต่อ) next to sentence, not new row. The read more text in first post is ok, but others not.

    - how can i set the thumbnail to align float left?

    Thank you so much in advance, your response is a big help for me :)

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    - The thumbnail does not show,

    possibly caused by your character set (?) - it is maybe the best to start a new topic just for the thumbnail problem.

    the other questions are related to the unique way your theme creates the excerpt, which also seems to be influenced by the 'more tag' if this exists in the post.

    I personally would remove the code and use the_excerpt() instead;
    you can then use all the instructions from http://codex.wordpress.org/Function_Reference/the_excerpt for the 'read more' link etc;
    the only thing is, you will not have links and linebreaks in the excerpt anymore.

    the section I suggested earlier would then look like:

    <?php the_post_thumbnail(); ?>
    
                 <span class="desc"><?php the_excerpt(); ?></span>
  5. Anchalee
    Member
    Posted 1 year ago #

    Hi, I've tried the new post, but the thumbnail still does not shown, also no image name was shown.

    http://www.buddhabucha.net/ - the test post has no image
    http://www.buddhabucha.net/test-4/ - in the post page has image

    If I need thee homepage to pull my custom excerpt which I add when I create/edit post, how can I do that. I've tried to add the custom excerpt, but it does not show on the homepage. Let's say that if we do not specify the excerpt length, but let it use the custom excerpt from each post.

    Thanks a lot again! Please don't getting bored with my simple question :)

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    If I need thee homepage to pull my custom excerpt which I add when I create/edit post, how can I do that.

    as alsready suggested, use the function the_excerpt() in index.php instead of the original code from the plugin.

  7. Anchalee
    Member
    Posted 1 year ago #

    Hi, alchymyth

    Thanks a lot, I can get the excerpt with the thumbnail already (can set thumbnail size).

    Really last question :) I cannot style the thumbnail. I review in your link, but I do not understand which file and where to add that code to, please advise.

    Thanks a lot for a big help!

  8. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    try to style the image by adding some styles to style.css;

    example:

    .attachment-post-thumbnail { float:left; margin-right: 10px; }
    .post h2 { clear:both; }

    the second style is needed to clear the next post title if a post is too short.

  9. Anchalee
    Member
    Posted 1 year ago #

    Thanksssss a lot!. I got everything I need now.

    Thank you for your help, wish you all the best :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags