Jump to content
raquel_p

A template for Custom Post Type

Recommended Posts

raquel_p

Still do not understand how to make templates for Post Custom Types in PlatformBase. I read http://www.pagelines.com/forum/discussion/comment/61577 and http://www.pagelines.com/docs/custom-sections, but it is not clear to me how create these templates. Should I use hooks, template.override, boxes or sections? I want to customize a post type (not a page), especially entering the information of Custom Fields. Like I would in loop.single.php, if was TwentyTen. Developers: A tutorial in Docs will solve the doubt of many people.

Share this post


Link to post
Share on other sites
raquel_p

I move/override/save in PlatformBase a template.postloop.php (from PlatformPro), with my custom post type name: template.custom.php. Is this correct? But, I don??t know how I register/call this template.

Share this post


Link to post
Share on other sites
Kate

Hi Raquel, Did you try Adam's solution yet? Of modifying template.postloop.php? If you do, please make sure to copy it to the base file first.

Share this post


Link to post
Share on other sites
raquel_p

Hello Kate, Thanks for the tip. But who is Adam (this is his nickname)? Could you give me the link to his solution.

Share this post


Link to post
Share on other sites
drwatson

Hi Kate, i have the same question and im very interesting about the solution from adam. I dont found the solution from him on his site. a link would help us...thanks!

Share this post


Link to post
Share on other sites
kastelic

The solution is very simple. Go to Custom Post Types UI settings and edit your post type. Click on advanced options, and then check "has archive". Thats it, it will create an archive page for you that uses the pagelines loop, so it looks just like any other blog page.

Share this post


Link to post
Share on other sites
raquel_p

Ok, I understand. Logical. But where it will save the template? Where do I find and what's its name? I tried and not found.

Share this post


Link to post
Share on other sites
kastelic

It uses template.postloop.php, just like every post, page and archive. Say the name of your post type is "hotels". Once you enable it, it will be active at www.yoursite.com/hotels.

Share this post


Link to post
Share on other sites
raquel_p

Hi Kastelic, First of all. Thank you for trying to help me. Unfortunately, I'm starting to feel stupid. My custom post types are active. I can access them with permalinks, categorize them, list them, put them in the home and feed. The problem is how to customize the loop them. I activated the option "has archive" and nothing has apparently changed. I can not access the specific template of my post types. See if I understand: I need to customize them in the template.postloop.php, creating a new copy of this file, and placing him in platformbase. No need to create a file separately for each post types. The question is which function to start the loop itself each post type. If it is not asking too much, you could give me a small example?

Share this post


Link to post
Share on other sites
raquel_p

Kastelic: See if you quite understand my question: I want to a post type template, like a single post, not an archive for post types, like a post archive. I need a postloop for my post types.

Share this post


Link to post
Share on other sites
kastelic

Okay, i gotcha. Here's a working example. Its a function I have placed in functions.php. It hooks into the loop, rather than having to edit the loop itself, although you could do that too by editing template.postloop.php. Its for a post type of "movie" and displays the contents of several custom fields created with the plugin Advanced Custom Fields, but you could use any worpdress tags like the_permalink, the_title, the_excerpt etc. The custom content comes after the post content, but you could use different hooks to place it wherever you need to.

	add_action('pagelines_loop_after_post_content','movies_loop');
	function movies_loop(){
	   if (is_singular( 'movie' )){
	      			if ( get_field('description', $post->ID) ) :
				?>
	            
<?php echo get_field('description', $post->ID) ; ?>
				<?php
				endif;
	
				if ( get_field('video_preview', $post->ID) ) :
				?>
	            
<?php echo get_field('video_preview', $post->ID) ; ?>
				<?php
				endif;
	
				if ( get_field('download_url', $post->ID) ) :
				?>
	            
Download Now
				<?php
				endif;
	
	   }
	}
	[/code]

Hope this helps.

Share this post


Link to post
Share on other sites
raquel_p

Kastellic, His example helped very much. I got success by entering the values ??‹??‹of the Custom fields, using the More Fields, with:



	
	But I found it strange that the code below, which is native to Wordpress, does not work with PlatformPro:
	
 ID, 'Custom Field', true);?>
Thanks anyway. I'm trying to enable my project, and it is not possible to build functions with the code of More Fields, because it is a direct command to echo. I need the:
 ID, 'Custom Field', true);?>.

working in PlatformPro. Do you know any alternative to this problem? It seems that using the Advanced Custom Fields, as in your example, is bypassing the problem. The strange thing is that the get_the_terms_list works perfectly. Ps. I entered my code in functions.php, the PlatformBase.

Share this post


Link to post
Share on other sites
raquel_p

Is solved! In any case, using the More Fields, Advanced Custom Fields or any of them. You can get the output by entering:

global $post;
The example of Kastellic would look like this:
add_action('pagelines_loop_after_post_content','movies_loop');
	function movies_loop(){
	   if (is_singular( 'movie' )); global $post; {
	
	                        
<?php echo get_post_meta($post->ID, 'description', true); ?>
				
<?php echo get_post_meta($post->ID, 'video_preview', true); ?>
				
<?php echo get_post_meta($post->ID, 'download_url', true); ?>
				
Download Now
	
	}
	}[/code]

It worked perfectly in my project. I hope this example will help other people.

Share this post


Link to post
Share on other sites
raquel_p

Correcting:

	add_action('pagelines_loop_after_post_content','movies_loop');
	function movies_loop(){
	   global $post;
	   if (is_singular( 'movie' ))  {
	
	  
<?php echo get_post_meta($post->ID, 'description', true); ?>
	  
<?php echo get_post_meta($post->ID, 'video_preview', true); ?>
	  
<?php echo get_post_meta($post->ID, 'download_url', true); ?>
	  
Download Now
	
	}
	}
	[/code]

Share this post


Link to post
Share on other sites
jankowalski1

both of the docuemnts in the file are giving 404 Error

Share this post


Link to post
Share on other sites
Simon
8 hours ago, jankowalski1 said:

both of the docuemnts in the file are giving 404 Error

This topic is from 2011 about PlatformPro

Please open a new topic..

  • Like 1

Share this post


Link to post
Share on other sites
jankowalski1

where is platform pro and pagelines framework forum support? it seems like the support for those products is abandoned.

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


×