Forums

Custom Content Type Manager
Unable to get Author info on single page (6 posts)

  1. msartori
    Member
    Posted 3 months ago #

    I have a CCT called insite. I'm able to print out the author's information on page-insite.php, but any function I call to retrieve author information on single-insite.php is either blank or seemingly incorrect.

    page version -> http://shp.wiredground.com/inside-shp/insite/
    single version -> http://shp.wiredground.com/insite/insite-tolles-career-tech-center/

    The following line is called from both pages:
    echo '<date>' . get_the_date('F j, Y') . '</date>, by <a>ID ) ) . '">' . get_the_author() . '</a>';

    - get_the_date() is returning "January 25, 2009" which is good.
    - $post->ID is returning 1014 which is also good.

    This is where it starts to fall apart...
    - get_post($post->ID) returns author info of ["post_author"]=> string(1) "1"
    but
    - get_the_author_meta( 'ID', $post->ID ) is returning int(0)

    Do you know of a reason (aside from me being an idiot) that I should see an ID of 1 for the author using get_post() and an ID of 0 using get_the_author_meta()? Maybe that's not even the issue.

    Thanks!

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Posted 3 months ago #

    I'm not sure what you're doing here... is this even related to the CCTM? These are all built-in WordPress functions. How are get_post() and get_the_author_meta() related? Are you tracking the author on your CCT? It's a checkbox when you define your post-type: CCTM --> Content Types --> Fields tab. If you aren't tracking the author on those pages, my guess is that WP is falling back to a default value.

  3. msartori
    Member
    Posted 3 months ago #

    Sorry - yes, it's using CCTM and I am keeping track of the author (the Author checkbox is checked in the Fields tab).

    I was trying to point out that it seemed odd that I'm able to get author information on the page- but not on the single-. I'm wondering if there's something I missed in the settings that may be preventing me from getting the author information.

  4. fireproofsocks
    Member
    Posted 3 months ago #

    Hmm... shouldn't your code reference the author id instead of the post id?

    <?php
    $my_post = get_post($post->ID);
    $author_id = $my_post['post_author'];
    $data = get_the_author_meta('some_custom_author_field', $author_id);
    ?>
  5. msartori
    Member
    Posted 3 months ago #

    You're right and I'm embarrassed. Sorry to have wasted your time.

  6. fireproofsocks
    Member
    Posted 3 months ago #

    no worries... if I had a nickel... ;)

Reply

You must log in to post.

About this Plugin

About this Topic