WordPress.org

Ready to get started?Download WordPress

Forums

Network Latest Posts
[resolved] No output for selected caregories (5 posts)

  1. sergeyzimin
    Member
    Posted 1 year ago #

    [nlposts title='' number='5' thumbnail=true auto_excerpt=true paginate=true display_root=true ignore_blog='1,2,5' paginate=true cat='crime-news']

    I have posts in specified category but got no output at all with your plugin.
    I have checked the code and put 'echo $filter_cat' before $filter_cat was inserted in sql string and look what i got:
    AND (ID = Array
    and that's how sql looks:
    SELECT ID, post_title, post_excerpt, post_content, post_author, post_date FROM wp_posts WHERE post_status = 'publish' AND (ID = Array ) AND post_type = 'post' AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 0 DAY) ORDER BY id DESC LIMIT 0,5

    Of course it does not work. Something wrong with your code.

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

  2. sergeyzimin
    Member
    Posted 1 year ago #

    wrong:
    $filter_cat = " AND ID = ".$postids{$blognlp};

    $postids{$blognlp} is array and was treated as a string.

  3. sergeyzimin
    Member
    Posted 1 year ago #

    if( count($postids{$blognlp}) == 1 ) {
    $filter_cat = " AND ID = ".$postids{$blognlp};
    if(!empty($filter_cat)) {
    if( !preg_match('/\(/',$filter_cat) ) {
    $needle = ' AND ';
    $replacement = ' AND (';
    $filter_cat = str_replace($needle, $replacement, $filter_cat);
    }
    }

    i don't understand why you need if(!empty($filter_cat)) because it cannot be empty anyway after $filter_cat = " AND ID = ".$postids{$blognlp}; and if count($postids{$blognlp}) == 1

  4. sergeyzimin
    Member
    Posted 1 year ago #

    So it should be like this:

    if( count($postids{$blognlp}) == 1 ) {
    $filter_cat = " AND ID = ".$postids{$blognlp}[0];
    if( !preg_match('/\(/',$filter_cat) ) {
    $needle = ' AND ';
    $replacement = ' AND (';
    $filter_cat = str_replace($needle, $replacement, $filter_cat);
    }

    and now it works

    This is real bug and you should fix it and update your plugin.

  5. Jose Luis SAYAGO
    Member
    Plugin Author

    Posted 1 year ago #

    Hello Sergey,

    Actually I'm impressed you could figure out that mess, it's full of hacks and nasty workarounds. I didn't have the time to properly code the plugin so I kept adding functionalities without testing too much all that stuff.

    All this is going to disappear in version 3. I've totally rewritten this to use WordPress hooks instead.

    Thanks for taking the time to solve this issue in the current release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.