• I’m using c2c customizable post listings plug-in (http://www.coffee2code.com/archives/2004/08/27/plugin-customizable-post-listings/) right now to modify how the post is shown.

    However, I’m having trouble showing posts by a single author. I’m adding the code to the author.php page, where I want it to be a profile/bio page + recent posts of that particular author.

    I would really like to find a way to make the author id value into a variable, instead of a constant number.

    I tried various things including:

    [in the plug-in file]
    $authors = ‘$author_id’,

    [in author.php file]

    Please let me know if it is even possible.

    – Kevin

Viewing 13 replies - 1 through 13 (of 13 total)
  • In your author.php, try something like this:
    <?php
    c2c_get_recent_posts (5, "<li>%post_date%: %post_URL%</li>", '', 'date', 'DESC', 0, 'm/d/Y', '$author', false)
    ?>

    If that doesn’t work, try this, to get the author ID:
    $author_ID = $wpdb->get_var ("SELECT ID FROM $wpdb->users WHERE user_name = '$author'");

    Thread Starter kikthinking

    (@kikthinking)

    where should i add the:

    $author_ID = $wpdb->get_var (“SELECT ID FROM $wpdb->users WHERE user_name = ‘$author'”);

    to?

    Immediately above the call to the c2c_get_recent_posts() function in your author.php. Then adjust the call to c2c_get_recent_posts() to use $author_ID instead of $author.

    Thread Starter kikthinking

    (@kikthinking)

    it gives me this error:

    WordPress database error: [Unknown column ‘user_name’ in ‘where clause’]
    SELECT ID FROM electronics_users WHERE user_name = ‘1’

    Sorry, try user_nickname instead.

    Thread Starter kikthinking

    (@kikthinking)

    nope…still the same. *sigh*.

    electronics.briefme.com is the site i’m testing it on right now.

    http://electronics.briefme.com/archives/author/administrator/

    What’s the problem?

    EDIT: never mind. I see that all authors’ pages are showing the same list of posts.

    Thread Starter kikthinking

    (@kikthinking)

    thank you very much by the way for your time.

    if i manually enter the author ID, everything is fine. so logically, shouldn’t it work also if i set author_ID as an integer variable? i can’t, for the life of me, figure out why it won’t work.

    $author_ID = $wpdb->get_var ("SELECT ID FROM $wpdb->users WHERE user_nickname = '$author'");
    echo c2c_get_recent_posts (5, "<li>%post_date%: %post_URL%</li>",
    '', 'date', 'DESC', 0, 'm/d/Y', $author_ID, false);

    That worked on my test blog. If you’re not using “nickname” in Options -> Profile to display your author name(s), you’ll need to adjust the first line.

    Note the lack of quotes around $author_ID. No quotes and double-quotes would work, but the single quotes as I used in my original suggestion will not work.

    Thread Starter kikthinking

    (@kikthinking)

    …still not working.

    what’s the URL for your site? i would like to check it out in action.

    Thread Starter kikthinking

    (@kikthinking)

    or rather, is there any other way to extract the author ID into a variable?

    Thread Starter kikthinking

    (@kikthinking)

    still nothing works. tried it on a different domain, but the same happens. i practically copy-pasted it exactly.

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

The topic ‘C2C Plug-In: All Posts by Single Author Problem’ is closed to new replies.