Jump to content


Photo

How do I create a new single-{post-type}.php template ?


  • Please log in to reply
9 replies to this topic

#1 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 26 July 2011 - 10:51 PM

I am using the Easy Custom Content Type plugin and its having great difficulty in creating new template for my custom post types. Now I have spoken to the author of the plugin and he has even logged on my test site to investigate the error and he had this to say. "PageLines is one of those themes that has used unconventional methods in their theme development. Template creation will NOT work with this theme." To which I asked, is there some kind of function I could add or could I manually create the templates for the custom post types. He replied with this. "The template creation won't work because the function has to have a valid template to copy before it can create the template. It would be worth while to just ask them "how do I create a single-{post-type}.php template in my child theme?". The question really, is whether or not you can simply copy single.php over from the parent theme to the child theme without causing any problems." So thats my question, how do I resolve this? Danny

#2 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 26 July 2011 - 11:39 PM

Its easy to create a custom page and a section to use within the page template. We have no idea how the plugin populates the page template or what it wants to put in there as its a closed source plugin. I'm sure one of these guys would be happy to code you a section http://www.pagelines.com/pros/ Of course if the main theme needs to be changed at all we can release a revision no problem.

#3 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 26 July 2011 - 11:44 PM

Im actually speaking to the developer now, as he is on my test site going over a few things, so I'll ask him, how his plugin populates the template so hopefully we can get this issue resolved. As the plugin itself is amazing. Thanks for the reply also. Danny

#4 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 26 July 2011 - 11:45 PM

Send me the plugin if you like simon@pagelines.com

#5 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 26 July 2011 - 11:54 PM

You got mail!

#6 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 27 July 2011 - 12:50 AM

Ok the plugin author as just got back to me and wrote this: "the plugin creates the templates based off of the already existing templates. It copies them to a new file and names them appropriately."

#7 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 27 July 2011 - 01:54 AM

hmm i got custom post types working without a plugin.
 
	add_action( 'init', 'register_cpt_book' );
	
	function register_cpt_book() {
	
	    $labels = array(
	        'name' => _x( 'books', 'book' ),
	        'singular_name' => _x( 'book', 'book' ),
	        'add_new' => _x( 'Add New', 'book' ),
	        'add_new_item' => _x( 'Add New book', 'book' ),
	        'edit_item' => _x( 'Edit book', 'book' ),
	        'new_item' => _x( 'New book', 'book' ),
	        'view_item' => _x( 'View book', 'book' ),
	        'search_items' => _x( 'Search books', 'book' ),
	        'not_found' => _x( 'No books found', 'book' ),
	        'not_found_in_trash' => _x( 'No books found in Trash', 'book' ),
	        'parent_item_colon' => _x( 'Parent book:', 'book' ),
	        'menu_name' => _x( 'books', 'book' ),
	    );
	
	    $args = array(
	        'labels' => $labels,
	        'hierarchical' => false,
	
	        'supports' => array( 'title', 'editor' ),
	
	        'public' => true,
	        'show_ui' => true,
	        'show_in_menu' => true,
	        'menu_position' => 5,
	
	        'show_in_nav_menus' => true,
	        'publicly_queryable' => true,
	        'exclude_from_search' => false,
	        'has_archive' => true,
	        'query_var' => true,
	        'can_export' => true,
	        'rewrite' => true,
	        'capability_type' => 'post'
	    );
	
	    register_post_type( 'book', $args );
		global $wp_rewrite;
		$wp_rewrite->flush_rules();
	}

now when i go to the admin there is a books section i can add book posts to.

when i go to http:blog/book/ i get a list of my book posts and if i click them it goes to singular books.
No need for custom templates.

The next version promises to have more support for CPT's

#8 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 27 July 2011 - 02:06 AM

Yeah I have already done that before, but the plugin makes life a little easier, the main reason why I want to get this automatic creation of the single.post-type.php files is so I dont have to have a singular list of the custom post types. I appreciate you going to all that trouble but that really doesnt help me Pross unfortunately.

#9 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 27 July 2011 - 02:09 AM

Not sure I understand what your after now, you want singular posts like /book1 /book2 /book3 etc but not the archive /books/ ?

#10 Danny

Danny

    Is Awesome!

  • Moderators
  • 17558 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 27 July 2011 - 02:13 AM

No, basically, I have a custom post for Players of a Football teams squad, then I have a taxonomy for "Current Squad" and "Legends". Now the way I wanted to set it up was to have the archive of all the players in a different setup to the singular method used for posts. I was going to set it so that all players were present, similar to how it looks on here. http://www.manutd.co...First-Team.aspx