Custom Content Type Manager
[resolved] CCTM posts have category, but not called into array (3 posts)

  1. blue522
    Posted 3 years ago #

    Hi FPS,

    Been staring at code for hours and need your clarity...

    I used CCTM last January to create CCT "players" for a team. At the time, Summarize Posts was in the process of being absorbed into CCTM, so I avoided it.

    Each player has a page. There is also a players page that shows some brief stats for each player, headshot, link to their personal page.

    Ran a bunch of updates today (WP 3.4.2, CCTM 9.6.1) and now my players page is blank.

    According to Posts>Categories, I have 7 players created and categorized as "players" (category 14). But when I call:

    $args = array( 'category'=>14, 'numberposts'=>-1 );
    $playerposts = get_posts( $args  );
    echo count($playerposts);

    I get "0".

    When I change the category to '18' (regular news post), I get an accurate count.

    Are CCTM categories the same as post categories? The above php worked prior to upgrade.

    Thanks for any advice,



  2. blue522
    Posted 3 years ago #

    Switched from 'category'=>14 to:

    and all is good now. posting here for others.

  3. fireproofsocks
    Plugin Contributor

    Posted 3 years ago #

    Thanks for sharing your solution. I think you may have gotten tripped up by the differences between taxonomies (i.e. categories) and post-types. They both represent valid ways of organizing your data, but the mechanics involved in searching for that data is vastly different. One of the reasons I wrote SummarizePosts (now included in CCTM) was because WP's inputs for its native get_posts() and WP_Query() et al were notoriously inconsistent and not as flexible as I wanted (e.g. sometimes they're only usable inside the loop).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic