SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    May 2010
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Custom Post Types Category Location

    I'm reviewing a site that a previous developer had worked on and trying to pick up where they left off.

    It seems they had created two post categories called "Upcoming Events" (slug = upcoming-events) and "Previous Events"(slug= previous-events). They also created a custom post type called "Events". In the custom post-type editor for anything under events "Events", both the "Upcoming Events" and "Previous Events" categories appear to the right of the editor under Categories. Each event has one of those 2 categories checked off.

    So how come I can't find a complete listing of upcoming events at any of these links:
    http://www.emazzanti.net/upcoming-events
    http://www.emazzanti.net/events/upcoming-events
    http://www.emazzanti.net/events
    http://www.emazzanti.net/category/upcoming-events
    http://www.emazzanti.net/category/ev...pcoming-events

    I cant imagine where else I would find the blogroll for this category.

    Please advise. Thanks in advance!

  2. #2
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    Open your functions.php file and try something like this:

    Code PHP:
    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) { 
     if(is_category() || is_tag()) { 
       $post_type = get_query_var('post_type');    
    if($post_type)     
       $post_type = $post_type;    
    else     
       $post_type = array('post','custom-post-type-name'); // add the name of your custom post type 
       $query->set('post_type',$post_type);    
    return $query; 
       }}
    Maleika E. A. | Rockatee | Twitter | Dribbble



  3. #3
    SitePoint Addict
    Join Date
    May 2010
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks but that did not work. i added this code exactly to the bottom of my functions.php file, in a new line right after the previous function ended with ?>

    PHP Code:
    <?php

    add_filter
    ('pre_get_posts''query_post_type');
    function 
    query_post_type($query) { 
     if(
    is_category() || is_tag()) { 
       
    $post_type get_query_var('post_type');    
    if(
    $post_type)     
       
    $post_type $post_type;    
    else     
       
    $post_type = array('events','upcoming-events'); // add the name of your custom post type 
       
    $query->set('post_type',$post_type);    
    return 
    $query
       }}

    ?>
    please advise. thanks in advance.

  4. #4
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    I have tried it and it works for me, so I'm not sure what else to advise. Sorry.
    Maleika E. A. | Rockatee | Twitter | Dribbble



  5. #5
    SitePoint Addict
    Join Date
    May 2010
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    which link? this one? http://www.emazzanti.net/events/

    that link just brings up a designed post and that's it. It's not even the most recent and its not the only one in the Events category. I'm looking for an archive page of all the events.

    please advise.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •