WordPress.org

Ready to get started?Download WordPress

Forums

exculde category with get_the_category (2 posts)

  1. mfalk75
    Member
    Posted 4 years ago #

    OK, just so you know I did find a post similar to this but it did not solve my problem and made me more confused. The code I am using looks like this.

    <?php
    $categories = get_the_category();
    $cat_ids = array();
    foreach( $categories as $category ) {
      $cat_ids[] = $category->cat_ID;
    }
    $map_args = 'width=590&height=300&map_content=global&open_post_id=' . get_the_ID() .
      '&marker_select_center=true&marker_select_highlight=true' .
      '&marker_select_highlight=true&marker_select_attachments=true' .
      '&map_cat=' . implode(',', $cat_ids);
    echo GeoMashup::map( $map_args );
    ?>

    Basically, it looks at the current post and identifies the categories and then uses them for a map plugin I am using. It works fine but say the current post has two categories, a parent category and a child category. It maps both of them but I really only want it to map the child. Is there a way to exclude the parent. Also, this parent category is always the same.
    Thanks,
    Michael

  2. mfalk75
    Member
    Posted 4 years ago #

    Anyone at all able to help with this? Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic