WordPress.org

Ready to get started?Download WordPress

Forums

Network Latest Posts
Excerpts.. (5 posts)

  1. SimplyMarkB
    Member
    Posted 1 year ago #

    Hey.. I am using a combination of NLPosts and Display posts on the same page.

    Test page here:
    http://sarasotamagazine.com/dining/

    I want to use the built in wordpress get_excerpt() instead of the one your using. Whenever I try to mod the network-latest-posts.php to add this support, I cant pull anything. I CAN however assign a random variable and get it to echo in it's place. :-(

    Any suggestions?

    -Simply Mark B

    http://wordpress.org/extend/plugins/network-latest-posts/

  2. Jose Luis SAYAGO
    Member
    Plugin Author

    Posted 1 year ago #

    Hello Mark,

    I'm wondering why would you want to use the built in WordPress get_the_excerpt() function? Is there something you need from get_the_excerpt() the plugin isn't doing right now?

    The main issue when using the default WordPress excerpt function is that it can't iterate when used outside of the loop, which means you will have to iterate and switch between blogs in order to pull all excerpts correctly.

    I've created a quick solution in case you want to use it, please keep a copy of your customizations because they will be erased when updating the plugin:

    1.- Replace the nlp_custom_excerpt by this one:

    function nlp_custom_excerpt($id,$blog_key){
        // Switch to the blog ID
        switch_to_blog($blog_key);
        // Get the post by post ID
        $post = get_post($id);
        // Go back to the current blog
        restore_current_blog();
        // This was taken from the WordPress Codex get_the_excerpt filter
        if ( post_password_required() ) {
            return __( 'There is no excerpt because this is a protected post.' );
        }
        // Check if an excerpt was found
        if( !empty( $post->post_excerpt ) ) {
            // Apply the WordPress excerpt filter and return the content
            return apply_filters( 'get_the_excerpt', $post->post_excerpt );
        } else {
            // If empty then return null..
            return;
        }
    }

    2.- Replace lines 737, 796, 963 & 1022 by this one:

    echo nlp_custom_excerpt($field->ID,$all_blogkeys[$field->guid]);

    To test if it works you could set your shortcode like this one:

    [nlposts title_only=false]

    This is a quick snippet, you may want to customize it even more, I hope this points you in the right direction.

    Best regards,
    José Luis.

  3. SimplyMarkB
    Member
    Posted 1 year ago #

    Hi Jose.

    I wanted to use the get_excerpt because we have to use the excerpt field as a subhead for articles. The excerpt option on the plugin as is ignored this and uses the first x words from the actual post as the excerpt, thus ignoring our subhead. I will try the solution above. Thanks!

    We WERE using the subhead plugin, but unfortunately its not allowing us to add subhead on the other blogs because its not WordPress network friendly apparently. :-/

    Also, we are trying to create a seamless look between your plugin and the display posts plugin. This way we can hand pick the first 3 posts and let your plugin pull the rest from across the network. Am I doing this the hard way?

    Thanks,
    Mark

  4. syntheticmotoroilstoday.com
    Member
    Posted 1 year ago #

    The reason being able to use the excerpt box on the add new posts and/or page page (I used the PJW Page Excerpt plugin to add it to pages also) is the fact some of my pages use shortcodes which look ugly. Being able to use the custom excerpt box makes all excerpts look clean. The network shared posts plugin allows you to do this but your plugin is better over all.

  5. Jose Luis SAYAGO
    Member
    Plugin Author

    Posted 1 year ago #

    @SimplyMarkB
    ===========
    Hi Mark,

    Well when I created this plugin I knew it would be impossible to suit everybody's needs, in case of interacting with third party plugins the only possible way right now is to tweak the code to make it work. However I'm taking notes, in order to try to improve support for third party plugins in the near future.

    Thanks for your feedback.
    ============

    Hi @syntheticmotoroilstoday.com I know when posts contain shortcodes excerpts display unexpected results. I'm adding this to my TODO list, lets see if it's possible to improve the excerpt function. Thanks for reminding me of this issue.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic