WordPress.org

Support

Support » Plugins and Hacks » Network Latest Posts » [Resolved] [Plugin: Network Latest Posts] No output for selected caregories

[Resolved] [Plugin: Network Latest Posts] No output for selected caregories

  • [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/

Viewing 4 replies - 1 through 4 (of 4 total)
  • wrong:
    $filter_cat = ” AND ID = “.$postids{$blognlp};

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

    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

    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.

    Plugin Author Jose Luis SAYAGO

    @iluminatus

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: Network Latest Posts] No output for selected caregories’ is closed to new replies.
Skip to toolbar