• I’m having a bizarre issue with items from a custom post type category only displaying intermittently. Items for a category on the custom post type display for some categories, but not for others, and I can get the stubborn categories to display again if I add an item to them, or any properly behaving category to disappear if any item is added to more than one category from this point on. I have some items displaying properly in more than one category, but any new item I try this with disrupts things.

    I don’t have any visible errors, the items show in the admin panel with no issue and display on their own individual page, but only on the taxonomy-project.php used to display the items in the category do they not show up (sometimes).

    For categories not displaying, adding a test item will make the category appear again. Adding that same item to more than one category makes both categories blank. If I save the test item to the original category, that categories items display again. Any existing item that I edit the categories it’s included in makes all the pages for those categories blank. This is the same behavior for all categories, including new categories created for testing. I do already have some items previously added that do successfully display in more than one category, but if they’re edited at this point, they stop displaying for all categories they’re added to. Once a category displays content, it will keep displaying it until I mess with the entries for that category in the admin panel.

    Despite playing around with new test items, one category wouldn’t display anything at all until I removed the “/” from the category name (“trees / flowers”), and now behaves like the other categories do. Other categories had a “/” in the name with no issue, however.

    When a category does not display, this query (code below from the taxonomy-projects.php file) seems to not execute at all, or come up blank as everything before and after in the taxonomy-project.php file displays; none of the divs in the query display at all. When the items do display for the category, they display correctly, both in layout and with the right items showing on the page.

    Query that seems to not execute when editing items in the custom post type:

    <?php
    						    $query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => -1, 'project' => get_the_term_list( $post->ID, 'project' )));
    						    while ($query->have_posts()) : $query->the_post();
    						    ?>
    							<div class="grid parent">
    								<div class="centered" align="center">
    									<div class="child"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
    									</div>
    								</div>
    								<!--<p><a href="<? the_permalink()?>"><?php the_title(); ?></a></p>-->
    							</div>
    					    	<?php
    					    	endwhile; wp_reset_query(); ?>

    I’ve tried repairing the database and repairing and optimizing via wp-config.php and this seems to have no effect. The repair did not list out the table for the custom post type.

    The function defining the custom post type:

    <?php 
    
    if ( function_exists( 'add_theme_support' ) ) {
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 280, 210, true ); // Normal post thumbnails
        add_image_size( 'screen-shot', 720, 540 ); // Full size screen
    }
    
    add_action('init', 'portfolio_register');  
    
    function portfolio_register() {
        $args = array(
            'label' => __('Portfolio'),
            'singular_label' => __('Project'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title', 'editor', 'thumbnail')
           );  
    
        register_post_type( 'portfolio' , $args );
    }
    
    register_taxonomy("project", array("portfolio"), array("hierarchical" => true, "label" => "Project Types", "singular_label" => "Project Type", "rewrite" => true));
    
    add_action("admin_init", "portfolio_meta_box");   
    
    function portfolio_meta_box(){
        add_meta_box("projInfo-meta", "Project Options", "portfolio_meta_options", "portfolio", "side", "low");
    }  
    
    function portfolio_meta_options(){
            global $post;
            if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
            $custom = get_post_custom($post->ID);
            $link = $custom["projLink"][0];
    ?>
        <label>Link:</label><input name="projLink" value="<?php echo $link; ?>" />
    <?php
        }
    
    	add_action('save_post', 'save_project_link'); 
    
    	function save_project_link(){
    	    global $post;  
    
    	    if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
    	        return $post_id;
    	    }else{
    	        update_post_meta($post->ID, "projLink", $_POST["projLink"]);
    	    }
    	}
    	add_filter("manage_edit-portfolio_columns", "project_edit_columns");   
    
    	function project_edit_columns($columns){
    	        $columns = array(
    	            "cb" => "<input type=\"checkbox\" />",
    	            "title" => "Project",
    	            "description" => "Description",
    	            "link" => "Link",
    	            "type" => "Type of Project",
    				"thumbnail" => "Thumbnail",
    	        );  
    
    	        return $columns;
    	}  
    
    	add_action("manage_posts_custom_column",  "project_custom_columns"); 
    
    	function project_custom_columns($column){
    	        global $post;
    	        switch ($column)
    	        {
    	            case "description":
    	                the_excerpt();
    	                break;
    	            case "link":
    	                $custom = get_post_custom();
    	                echo $custom["projLink"][0];
    	                break;
    	            case "type":
    	                echo get_the_term_list($post->ID, 'project', '', ', ','');
    	                break;
    				case "thumbnail":
    					the_post_thumbnail();
    					break;
    	        }
    	}

    I tried downloading the xml backup and importing it onto a new site on a MU install I use for development to see if the issue replicates there. In checking “import attachments”, it imported some of the media files and none of the pages or custom posts (portfolio) imported, so I can’t even get a testing environment working.

    I suspect it’s a database issue or perhaps something in the function defining the custom post category. Any help with this is greatly appreciated. I’m at a loss for fixing this issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • jack randall

    (@theotherlebowski)

    try resaving your permalinks, it can help to kick the .htaccess file into shape which handles url’s and redirects to make categories etc show right.

    Thread Starter johnnybebopcool

    (@johnnybebopcool)

    I’ve tried both of those things to no effect. =/ Additionally, I’m able to get content on the categories to display and hide without changing permalinks or .htaccess by just editing the post type entries in the admin panel.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Content in custom post type category not displaying intermittently’ is closed to new replies.