Support » Plugins » Custom Post Types and Plug-ins

  • sanzone13


    I’m working on a plug-in for my website which parses a remote XML file, collects data from that file, and creates a single entry of a new custom post type I created per record in the XML file.

    I’m getting the xml and parsing it fine. The custom post type entries are getting generated just fine (they show up inside WordPress Admin correctly listed under the newly defined custom post type). The only issue I seem to be having is that when I go to view my custom post types on the live site I’m getting “Sorry, no posts matched your criteria.” (which is my standard output for the loop not returning any posts). I tried even the top level ( of the custom post type and it’s still returning no posts rather than an archive listing.

    Any idea what I’m doing wrong?

    Here is my custom post type code:

    register_post_type('characters', array('labels' => array('name' => _x('Characters', 'post type general name'),
                                           'singular_name' => _x('Character', 'post type singular name'),
                                           'add_new' => _x('Add New', 'characters'),
                                           'add_new_item' => __('Add New Character'),
    					 'edit_item' => __('Edit Character'),
    					 'new_item' => __('New Character'),
    					 'view_item' => __('View Character'),
    					 'search_items' => __('Search Characters'),
    					 'not_found' => __('No characters found.'),
    					 'not_found_in_trash' => __('No characters found in trash.'),
    					 'parent_item_colon' => __('Parent Character:')),
    				 'public' => true,
    				 'exclude_from_search' => true,
    				 'show_ui' => true,
    				 'capability_type' => 'post',
    				 'hierarchical' => false,
    				 'supports' => array('title'),
    				 'menu_position' => 9,

    And here is my wp_insert_post code:

    function wowgr_generate_roster($xml)
    	$doc = new DOMDocument();
    	$roster = $doc->getElementsByTagName('character');
    	foreach($roster as $toon)
    		$post = array('post_title' => $toon->getAttribute('name'),
    	'post_name' => strtolower($toon->getAttribute('name')),
    	'post_type' => 'characters',
    	'post_author' => $user_ID);
    		$post_ID = wp_insert_post($post);

    As you can see I’m not really tying to do much… just parse the file and create new entry of custom post type “characters” for each entry using the character’s name as the post “title.”

    It all works just won’t show me the page on the live site.

  • The topic ‘Custom Post Types and Plug-ins’ is closed to new replies.