BuddyDev

Search

Post excerpt

  • Participant
    Level: Initiated
    Posts: 16
    Scooter on #52455

    Is there a way to auto generate the post excerpt rather than having to type one out manually, e.g. by automatically selecting the first 30 words of the post content?

  • Participant
    Level: Initiated
    Posts: 16
    Scooter on #52456

    This is regarding BuddyBlog Pro.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52462

    Hello Scooter,

    Thank you for posting. If you are familiar with PHP you can use the function name “wp_trim_excerpt” to generate. If you want me to assist you with the code let me know.

    Regards
    Ravi

    • This reply was modified 6 months, 2 weeks ago by Ravi.
  • Participant
    Level: Initiated
    Posts: 16
    Scooter on #52473

    Thanks Ravi. I would appreciate some help please, as I’m not sure where to make the changes.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52478

    Hello Scooter,

    Thank you for the acknowledgement. Do you have already post excerpt with the posts? If yes please delete and WordPress will auto-generate it for you. By default, WordPress shows 55 words in a post excerpt but with the following code you can control the excerpt words length.

    
    
    add_filter( 'excerpt_length', function () {
    	return 30;
    } );
    
    

    You can place this code in “bp-custom.php” file or your active theme “functions.php” file.

    You can refer the URL: https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Please give it a try.

    Regards
    Ravi

    • This reply was modified 6 months, 2 weeks ago by Ravi.
  • Participant
    Level: Initiated
    Posts: 16
    Scooter on #52480

    Thanks Ravi. I deleted “post excerpt” from my form and it now auto generates. I also tried creating the bp-custom.php and put this file in wp-content/plugins and changed the length to 100, however it didn’t work. Have I put the file in the correct place? Under plugins there is the buddyblog-pro folder. Should it not be in there?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52483

    Hello Scooter,

    Thank you for the acknowledgement. You can place the file “bp-custom.php” under “wp-content/plugins”. Make sure you have started the file with

    
    <?php
    
    

    Note: Ensure there is no space or a new line before “<?php” tag.

    if still not working put the code in the active theme “functions.php” file and then check it.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved