Support » Themes and Templates » archive.php looping custom post type not the posts

  • Resolved sdjentertainment

    (@sdjentertainment)


    Hello Fellow WP’ers

    I’ve been working on a theme, mainly the archive.php file and it’s doing something I’ve never seen before.

    Inside my sidebar I have the following and everything is working just fine.
    <?php wp_get_archives(‘type=monthly’); ?>

    However, when I click on any link generated from the above I get to the archive.php template and the loop returns the first post from a custom post type, and nothing from the built in posts in WP.

    Just wondering if anybody out there has experienced this problem before.

    Cheers,
    Simon

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    (@esmi)

    Forum Moderator

    Sounds like you need to call wp_reset_query() before your sidebar.

    I tried that out but still nothing, any other ideas.

    Even tried using the archive and loop files from the default theme. Along with disabling all the plugins

    I do have a custom taxonomy of Year. Which seems to be throwing things off. I disabled the taxonomy and the archives, work as expected. However I do need to have the Year taxonomy since it’s the year the custom post type (Project) got completed, not the date it was posted.

    Know of any work arounds?

    esmi

    (@esmi)

    Forum Moderator

    Make a copy of Twenty Eleven called something like “Test”. Edit sidebar,php in Test and add <?php wp_get_archives('type=monthly'); ?>. Now see if you can replicate the problem.

    Uploaded a fresh copy of the theme, everything including the archives worked just fine.

    Then dove into the functions.php file and implemented the custom taxonomy of year, which has values of “2012, 2010, 2009, etc.”

    Checked the site and it wasn’t working. Commented out the Year taxonomy and everything went back to normal working good as gold.

    Following is the registering taxonomy code, through a function…

    $labels = array(
        'name' => _x( 'Year', 'taxonomy general name' ),
        'singular_name' => _x( 'Year', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Year' ),
        'all_items' => __( 'All Year' ),
        'parent_item' => __( 'Parent Year' ),
        'parent_item_colon' => __( 'Parent Year:' ),
        'edit_item' => __( 'Edit Year' ),
        'update_item' => __( 'Update Year' ),
        'add_new_item' => __( 'Add New Year' ),
        'new_item_name' => __( 'New Year Name' ),
        'menu_name' => __( 'Year' ),
      ); 	
    
      register_taxonomy('Year',array('project'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'year' ),
      ));
    esmi

    (@esmi)

    Forum Moderator

    Commented out the Year taxonomy

    Ah! “Year” is a really bad title/name for a custom taxonomy.

    Anyway to change it without loosing all the “Year” taxonomy information?

    esmi

    (@esmi)

    Forum Moderator

    Not that I know of. And considering the potential implications of having a Year taxonomy in a web app that is essentially date based anyway, I’m not sure just how good any saved data will be.

    Sounds good, Thanks a lot for the help, been running around in circles for the past few days.

    Cheers,
    Simon

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘archive.php looping custom post type not the posts’ is closed to new replies.