WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] archive.php looping custom post type not the posts (10 posts)

  1. sdjentertainment
    Member
    Posted 2 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 2 years ago #

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

  3. sdjentertainment
    Member
    Posted 2 years ago #

    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

  4. sdjentertainment
    Member
    Posted 2 years ago #

    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?

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  6. sdjentertainment
    Member
    Posted 2 years ago #

    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' ),
      ));
  7. esmi
    Forum Moderator
    Posted 2 years ago #

    Commented out the Year taxonomy

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

  8. sdjentertainment
    Member
    Posted 2 years ago #

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

  9. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  10. sdjentertainment
    Member
    Posted 2 years ago #

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

    Cheers,
    Simon

Topic Closed

This topic has been closed to new replies.

About this Topic