Custom Content Type Manager
Display all 'posts' by author (2 posts)

  1. oakley56fila
    Posted 4 years ago #

    On each post, I would like to add a link to all other posts by that specific author. I searched for and found this: <?php the_author_posts_link(); ?>. More information here: http://codex.wordpress.org/Function_Reference/the_author_posts_link. It looks like that should work, but it does not. I'm wondering if it is that the posts created by this plugin aren't true 'posts' that can be listed using this function..?


  2. fireproofsocks
    Plugin Contributor

    Posted 4 years ago #

    They are all "true" posts: the CCTM plugin builds post-types in exactly the same way WordPress does (see the readme description: no artificial ingredients here -- I don't waste my time with unnatural perversions of the model), but keep in mind WP itself is sorta hodge-podge code, often made up of contributions from amateur coders, so your mileage may vary.

    The the_author_posts_link() function takes no arguments, so that's a smoking gun that it relies on global variables, which in my mind, makes that function practically useless, victim to short-sighted architecture because global variables are @!%!@ retarded. (yes, I'm very outspoken about that sort of stuff)

    You could do a database query to search by author. WP has its own ways to do this, but I've found more than a handful of WP "solutions" to be as short-sighted as the the_author_posts_link() function, i.e. they have weird caveats and don't work well. If you were writing a raw database query, it'd look something like this:

    SELECT * FROM wp_posts WHERE post_author='1';

    (assuming an author ID of 1). Very simple.

    So if you can get ahold of your author ID (i.e. the post_author), you could do something like this using the GetPostsQuery class (bundled in the CCTM):

    global $post;
    print $post->post_author; /* <-- better make sure you can actually get the author ID before you go any further.  Depending on where you try to do this, the author ID may be stored elsewhere. */
    // In your template file somewhere
    $Q = new GetPostsQuery();
    $args = array(); // initialize
    $args['post_author'] = $post->post_author;
    $posts = $Q->get_posts($args);
    // Iterate over your results.
    foreach ($posts as $p) {
        print $p['post_title'] . '<br/>';

    Hope that helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic