• Resolved Leime

    (@leime)


    Hi,

    I’m trying to get this plugin to work directly in a template file by using the <?php echo do_shortcode() ;> function. However if I try to put in specific options, some of them seem to work while others don’t.

    For instance this code works (showing 3 posts per site):
    <?php echo do_shortcode (‘[nlposts number_posts=”3″]’) ;?>

    But this one does not (trying to show just 3 posts all together):
    <?php echo do_shortcode (‘[nlposts number_posts=”3″ sorting_limit=”3″]’) ;?>

    Also trying to set some options to “TRUE” does not seem to work.

    Any suggestions?

    Thanks!

    https://ww.wp.xz.cn/plugins/network-latest-posts/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Hello Leime,

    If you want to embed Network Latest Posts into a template file, please use the following structure:

    // Check if the plugin has been activated
    if( function_exists( 'network_latest_posts' ) ) {
        /**
         * Custom Parameters
         * Set only those you want to use
         */
        $parameters = array(
          'title'         => 'Recent Articles'
          'title_only'    => 'false',
          'auto_excerpt'  => 'true',
          'random'        => 'true'
        );
        // Execute
        network_latest_posts( $parameters );
    }

    Also you must set sort_by_date => 'true' or sort_by_blog => 'true' when using sorting_limit=5 otherwise it won’t work.

    Let me know if this helps.

    Best regards,
    Jose SAYAGO.

    Thread Starter Leime

    (@leime)

    Hi Jose,

    Wow quick response! And works like a charm, thank you so much!

    Plugin Author Jose Luis SAYAGO

    (@iluminatus)

    Hey Leime,

    Thank you for your feedback, I am glad you made it work. Happy blogging!

    Cheers,
    Jose SAYAGO.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘usage with do_shortcode in php template file’ is closed to new replies.