• I’m making a plugin which will give me a list (with images and links) of a few selected authors ordered by the most recent post date… but I only get the image border and link but no author… could someone help me point out what I’m doing wrong here… (not a programmer… built this code by quickly glancing at php and wordpress plugin files)

    function pfc_author_list($before = ”, $after = ‘
    ‘) {

    global $wpdb;

    $pfcrequest = “SELECT $wpdb->users.user_login, $wpdb->posts.post_status, Max($wpdb->posts.post_date) AS ‘pfcpostdate’ FROM $wpdb->users, $wpdb->posts”;

    $pfcrequest .= ” WHERE ID IN (’73’,’39’,’52’,’54’,’64’,’60’,’71’,’98’,’134′,’142′,’101′,’141′,’144′) AND $wpdb->users.ID=$wpdb->post.post_author AND $wpdb->post.post_status = ‘publish'”;

    $pfcrequest .= ” GROUP BY $wpdb->users.user_login ORDER BY pfcpostdate DESC”;

    $pfclist = $wpdb->get_results($request);

    $pfcoutput = ”;

    if ($pfclist) {

    foreach ($pfclist as $pfclist) {

    $pfcauthor = $pfclist->user_login;

    $pfcauthorlink = ‘<a href="https://passionforcinema.com/author/' . $pfcauthor. '" title="Click here to read the diary of ' . $pfcauthor. '"><img src="https://passionforcinema.com/images/' . $pfcauthor. '.jpg" style="border:solid #0B256F 1px;" /></a>’;

    $pfcoutput .= $before . $pfcauthorlink . $after;

    }

    } else {

    $pfcoutput .= $before . “None found” . $after;

    }

    echo $pfcoutput;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter zapata

    (@zapata)

    ok I corrected one mistake above : get_results(pfcrequest);

    now I see this error:

    [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND .post_status = ‘publish’ GROUP BY wp_users.user_login ORDER BY pfcpostdate D’ at line 1]
    SELECT wp_users.user_login, wp_posts.post_status, Max(wp_posts.post_date) AS ‘pfcpostdate’ FROM wp_users, wp_posts WHERE ID IN (’73’,’39’,’52’,’54’,’64’,’60’,’71’,’98’,’134′,’142′,’101′,’141′,’144′) AND wp_users.ID=.post_author AND .post_status = ‘publish’ GROUP BY wp_users.user_login ORDER BY pfcpostdate DESC
    None found

    Thread Starter zapata

    (@zapata)

    ok… i resolved the issue… closing this case.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Making first plugin… but it’s not working’ is closed to new replies.