Jump to content
Sign in to follow this  
shmokes

How to make templates for custom post types

Recommended Posts

shmokes

I created three custom post types for a review website, and I want to change the post template for each type to automatically insert a table and some shortcodes on every post. I want different things on the posts for each different custom post type, so I can't just change the default single.php template. I got a plugin called Custom Post Type Template Redirect that should cause WP to look for a template for each of the custom post types, for example a books.php, in the theme folder that contains index.php (so the Platform Pro folder, rather than the Platform Base folder). But I suspect that this won't work because of the non-standard way that Platform Pro works. From what I understand, all of Platform's post template stuff is in template.postloop.php. At the very least, I can't really use single.php as a guide for creating custom templates because Platform Pro's single.php isn't really anything. Will this plugin work under Platform Pro, or do I need to go about this in a totally different way. I don't want to activate the plugin and create new files and have it screw up my Platform installation. Here's a link to the plugin: http://wordpress.org/extend/plugins/custom-post-type-template-redirect/ Thanks for your help. I'm just getting started with PHP and Wordpress, so many of the things I'm doing with my website are probably a bit more ambitious than they should be. But I figure, the more I go for, the more I'll learn in the process.

Share this post


Link to post
Share on other sites
catrina

The PlatformPro structure will make a difference in how the custom post types can be implemented, so I think a different approach will need to be used with the PHP.


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
shmokes

The non-Standard Platform structure sure seems like a double-edged sword. On the one hand, I have managed to make a really beautiful website with just a lot of determination (but not a lot of prior web knowledge). On the other hand, the wealth of information all over the internet about how to accomplish various things in WordPress is often totally inapplicable, which seems like an awful waste of a great resource. Thus, any customizations a newbie wants to make that Platform has automated are much easier. But if Platform hasn't automated it, it's actually far more difficult (or at least requires more expertise) to accomplish various tasks. From what I understand, in a typical WordPress installation, custom post templates can be made by simply copy/paste/renaming the single.php and then editing the new file to add customization. This can be accomplished through trial and error by determined newbies who don't know PHP by copying templates from people who have already done the same thing for similar websites. And in the process, the newbie slowly learns the code. Pagelines has replaced this relatively straightforward process with what seems to me to be a far more complicated process. And since Pagelines Platform users are a very very very small subset of WordPress users in general, there just aren't nearly as many people running into similar issues and posting their code online, so figuring out the code for customizations in Platform requires some prior php expertise. I may just be off-base here with my frustration. Like I said in my first post, my ambitions are maybe just too high for someone with no PHP knowledge. But I can't help but sense inadequate documentation for a system that deviates so far from standard practices.

Share this post


Link to post
Share on other sites
Rob

Hi, Actually, Platform is much simpler than any other theme or platform associated with Wordpress. I searched for two years before finding it in order to make my site look as I wanted and since then it's been great. Yes, there are times when a high level of customization requires assistance, which is what we're here trying to do. However, we must all consider that the support obtained is in the context of a forum. It's for this reason that we offer our Pros for those clients who seek a high level of customization or don't have the skills to implement the snippets of code we can provide here. I strongly suggest you visit http://www.pagelines.com/pros and contact them. Consider if you will that whatever the cost, saving your time and avoiding frustration are more valuable. Or Pros are incredibly good. As for the standard practices - well, the reason that so many Wordpress sites have the same look and feel is that they're standard, out of the box and limited. Pagelines does afford anyone, even the inexperienced, to create awesome looking websites. I can say this with impunity as I'm no webmaster by any measure - an economist and chef - and still I've been able to use it with no training and did, I think, pretty well. I am confident you can benefit from a limited amount of time with a Pro and get your site looking exactly as you wish.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
shmokes
Yeah, I don't mean to berate Platform as a platform generally speaking. Like I said, I'm almost finished with my site and it's looking really great. I just got a bit frustrated trying to make custom post templates and finding loads of information about how to make/display them, only to find that the information applied to nearly every WP user except me (and other Platform users). Even with that being the case, though, I'm not tempted to leave Platform. On the contrary, I'm generally very happy with the results I've had with it.

Share this post


Link to post
Share on other sites
kastelic
The way i've done this is the past is to use hooks in functions.php. Here is an example of one that will put some text at the top of your custom post type. [code] add_action('pagelines_loop_before_post_content', 'hotel_info'); function hotel_info(){ if( get_post_type() == 'hotels' ) { echo "this is the hotels post type"; } [/code]

Share this post


Link to post
Share on other sites
shmokes
Thanks for the help. However, I think there may be something wrong with that code, as breaks my site completely, returning the following error in my browser: ********************************************************* Parse error: syntax error, unexpected $end in /homepages/22/d334612527/htdocs/Sites/Test/wp-content/themes/platformbase/functions.php on line 107 ********************************************************* For reference, line 107 isn't anything. It's just the final line in my functions.php and it is commented out. I thought maybe I was just editing your code to make it work with my custom post types, so I created a new custom post type called 'Hotels' and then I inserted your code exactly as written, and it still broke my site. Any idea what might be wrong? Thanks

Share this post


Link to post
Share on other sites
kakadong
add_action('pagelines_loop_before_post_content', 'hotel_info'); function hotel_info(){ if( get_post_type() == 'hotels' ) { echo "this is the hotels post type"; } } I think one { is lost.....

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  

×