Jump to content
Sign in to follow this  
shmokes

How to make custom page templates?

Recommended Posts

shmokes

I'm making a review website for kids iPad apps. I've created separate categories for books, games, and educational apps, but I want to divide each of those by age groups. To that end, I want some double-category pages that will, for example, display all posts in BOTH the Books and the Age: 1-4 categories. And I want another that shows all posts in Both the Books and Age: 5-9 categories. And so on. From what I understand, I should create new page templates with lines like: "query_posts( array( 'category__and' => array(books,Age_1-4)" or something. Anyway, I was going to just copy all the text from page.php into my new template files and then add that line to it, but once I opened page.php it seemed like maybe Platform works differently than the default Wordpress setup. I found the document page re: Child Sections and Templates, but that page is super useless. Any chance someone can point me in the right direction? Although I don't know what I'm doing, I'm pretty good at researching until I figure out what I need. But the Pagelines docs on custom template pages isn't helping at all.

Share this post


Link to post
Share on other sites
Danny

I could be wrong but wouldnt it be easier to simply use Custom post types ? I use this plugin, not saying you should but on the link below there is a few useful videos, which may help you! http://pippinsplugins.com/easy-content-types/


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
jane_l

I would love to know the answer to this as well. The reason that I want to create a custom template is because I want to exclude certain code and features.

Share this post


Link to post
Share on other sites
shmokes

dannyh, I think you are right that custom post types and custom taxonomies will serve my purposes, and after checking out that plugin that you use, I decided to purchase it. It doesn't seem to be compatible with Platform Base (Platform Pro using the Base child theme to enable customization). Are you using that plugin with Base? Whenever I create a custom taxonomy with the Base theme enabled I get an error message at the top of the screen for each custom post type or taxonomy I've created that looks like this: Warning: copy(/homepages/22/d334612527/htdocs/Sites/BestKidIpadApps/wp-content/themes/platformbase/index.php) [function.copy]: failed to open stream: No such file or directory in /homepages/22/d334612527/htdocs/Sites/BestKidIpadApps/wp-content/plugins/easy-content-types/includes/register-post-types.php on line 79 Any ideas? Once I can get custom post types working properly I can decide for sure whether I can accept your answer and close this discussion. Thanks for your help.

Share this post


Link to post
Share on other sites
kastelic

I've used the plugin Custom Post Types UI many times with base and it worked well.

Share this post


Link to post
Share on other sites
shmokes
Custom Post Types UI does work perfectly well. For reference, I was able to figure out the problem with Easy Custom Content Types as well. Under settings it had options to enable automatic single template creation for custom post types, custom post type archives, and for custom taxonomy archives. These options are the only thing that is incompatible with Pagelines Platform. I was happy to figure it out, because I prefer Easy Content Types user interface, and it also a very intuitive and powerful Meta Boxes feature built-in, which negates the need for the Advanced Custom Fields plugin that you need to get similar (though inferior, I think) functionality with Custom Post Types UI.

Share this post


Link to post
Share on other sites
Danny
Hi Shmokes, Yes, sorry, I did forget to mention that the automatic creation of templates doesn't work with Platform. I do have custom template working with Easy Content Types though, so if you would like me to post how to do this, just reply to this post and I'll share how to do it.

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
shmokes
I am definitely interested in seeing your method. I've managed to get something going, but I am trying to learn as much as possible so I'd be interested to see if your method differs from mine.

Share this post


Link to post
Share on other sites
knubbl
I would be interested in it too. I can't seem to find a solution on how to create custom templates and how to display these content types right.

Share this post


Link to post
Share on other sites
Danny
@Shmokes @Knubbl OK, here goes, wall of text inc... I would recommend you have a test site ready, just to make sure before doing this on a live site. 1. The first thing you are going to need to do is open up functions.php (via FTP) located in /themes/platformbase/ a) Once functions.php is open, search for this line of code: [code] // ABOUT HOOKS --------// [/code] b) add this code above it: [code] pagelines_register_section('PageLinesPostLoopCPT','cptloop', null, array('child' => true) ); pagelines_register_section('PageLinesContentCPT','cptsingle', null, array('child' => true) ); [/code] 2. Create two new files using your favourite text editor and call them: section.cptloop.php section.cptsingle.php a) Now add the code provided in the link below to section.cptloop.php http://pastebin.com/WkuGRdeX Once the code has been added, save the file. b) Now add the code provided in the link below to section.cptsingle.php http://pastebin.com/SkL8AcQk Once the code has been added, save the file. c) Upload theses two files to /wp-content/themes/platformbase/sections 3. Now if you goto Platform Settings --> Template Setup, go through all the templates and if any of the templates have either the Content Section or Main Content (The Loop - Required) section, replace them with the new sections you have. These new sections are called: Content Area (CPT ENABLED) Main Content (The Loop - CPT ENABLED) Once that is done, your ready to go, all you need to do now is create your custom template for your Custom Post Types. How to create a template for a custom post type (Single) Using your favourite text editor add this code: [code]
layout_mode == 'two-sidebar-center'):?>
[/code] Once the code has been added you need to save the file and calle it this: template.single-CUSTOM POST TYPE NAME.php Replace CUSTOM POST TYPE name with your custom posts type name for example if you have a post type called Books the file name would look like this: template.single-book.php Now upload the file to /wp-content/themes/platformbase/ Remember this is for a single custom post type so you use the singlular name, so not books but book. How to create a Archive template for your Custom Post type. Now from what I can remember this file isn't needed, but if you don't want the standard style of your custom posts types looking like a regular blog layout, with a list of posts, then this file is for you. Using your favourite text editor save the file and call it: template.archive-CUSTOM POST TYPE NAME.php Replace CUSTOM POST TYPE name with your custom posts type name for example if you have a post type called Books the file name would look like this: template.archive-books.php Now upload the file to /wp-content/themes/platformbase/ In this file you can add any HTML you want. An example of this can be seen here. http://www.redofmanchester.com/squad-members/ As you can see, if I never used this file, then the style of the page would be that of a blog layout. All I did to create the archive page of all the players images, was the use basic HTML/CSS and nothing more. Hope you find this useful and credit for the custom sections goes to Pagelines Dev Pross. Remember, if you run into any errors, make sure you have followed this guide completely and check for any errors in your custom post type name(s) in the file name.

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
memeshift
WOW. Thanks you SO much for posting this detailed description! Great stuff. Delicious'ed!

Share this post


Link to post
Share on other sites
knubbl
I shouldn't place the same code into the archives template as the single template, right?! What are you supposed to put into the archives template, what code?! Thanks

Share this post


Link to post
Share on other sites
Danny
Well Anything you like, as I mentioned my squad members archive page, the only thing in that template is HTML thats it, nothing else and the result is what I linked. So have a play around and see what you can some with!

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
johnny_n
This is great... finally a good answer to my thread from August http://www.pagelines.com/forum/discussion/12926/template-for-custom-post-type-archive/ This info should go in the Platform Pro documentation...

Share this post


Link to post
Share on other sites
marvage
This is great. Thank you so much for the instructions Danny.

Share this post


Link to post
Share on other sites
jankowalski
This is really great tutorial. Now i d like to list on archive page all custom posts titles with thumbs and display them 4 in a row. As i understood, i have to insert some code to template.archive-books.php any sample code so i could play with it?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×