• 0
Sign in to follow this  
Followers 0

Custom Post Types

Question

Posted · Report post

Hi, I've just installed the platform pro update and have added a custom post type in my child theme. I have added several new meta fields to this for a catalog of boats. These are saving correctly, but how do I make these visible on my custom post. This is the link to the test server: http://mon956.djhands.com/portfolio/astinor-1245/ The custom post is called portfolio and in a normal template I would used single-portfolio.php - I don't think this is applicable in platform pro. Thanks, Rich

Share this post


Link to post
Share on other sites

10 answers to this question

  • 0

Posted · Report post

Hi Richard, Actually, PlatformPro now supports custom templates. Which version are you running, please? If you have base activated, there should actually be an example in there as well.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Kate, I have PlatformPro 1.5.0 and PlatformBase 1.4.1. Is that the most up to date? I upgraded this morning to take advantage of the custom post types. Rich

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi Richard, Yep... that should be good. Did you see the example in base?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

all posts/pages are handled by one file in PP...template.postloop.php. You can use this file in conjunction with wordpress conditionals to create the custom post type output.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks for the responses guys. Very new to Wordpress and php (background in ColdFusion) - so this is all a bit tricky. I've solved this all now using hooks and the functions.php file in the child theme. Looking forward to more customisation!!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well done for solving it, any chance you can post your snippets for next person?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

To start off with I needed to add my extra meta information to the bottom of a custom post. Like all of this customisation it was carried out in the fucntions.php file of the child theme. Add Custom Meta to Post

add_action('pagelines_inside_bottom_theloop', 'boat_meta_info');
	
	function boat_meta_info() {
	
	$this_boat_info = get_post_meta( $post_id, 'portfolio' );
	
	global $post;
	  $custom = get_post_custom($post->ID);
	  $boat_make = $custom["boat_make"][0];
	  $boat_model = $custom["boat_model"][0];
	  $boat_year = $custom["boat_year"][0];
	  $boat_length = $custom["boat_length"][0];
	  $boat_beam = $custom["boat_beam"][0];
	  $boat_fuel = $custom["boat_fuel"][0];
	  $boat_water = $custom["boat_water"][0];
	  $boat_price = $custom["boat_price"][0];
	
	if ( ! empty( $boat_make ) ) {
	
	?>
	<p><h3>Details</h3></p>
	<p align="center">
	  <table style="border:0;">
	      <tr>
	          <td width="230" align="right">Marca : </td>
	          <td width="200" align="right"><?php echo $boat_make; ?></td>
	          <td align="left"></td>
	      </tr>
	      <tr>
	          <td align="right">Modelo : </td>
	          <td align="right"><?php echo $boat_model; ?></td>
	          <td align="left"></td>
	      </tr>
	      <tr>
	          <td align="right">Año : </td>
	          <td align="right"><?php echo $boat_year; ?></td>
	          <td align="left"></td>
	      </tr>
	      <tr>
	          <td align="right">Eslora : </td>
	          <td align="right"><?php echo $boat_length; ?></td>
	          <td align="left"> M</td>
	      </tr>
	      <tr>
	          <td align="right">Manga : </td>
	          <td align="right"><?php echo $boat_beam; ?></td>
	          <td align="left"> M</td>
	      </tr>
	      <tr>
	          <td align="right">Depósito del combustible : </td>
	          <td align="right"><?php echo $boat_fuel; ?></td>
	          <td align="left"> L</td>
	      </tr>
	      <tr>
	          <td align="right">Depósito del agua : </td>
	          <td align="right"><?php echo $boat_water; ?></td>
	          <td align="left"> L</td>
	      </tr>
	      <tr>
	          <td align="right">Precio : </td>
	          <td align="right"><?php echo $boat_price; ?></td>
	          <td align="left"> €</td>
	      </tr>
	  </table>
	</p>
	<?php
	}
	}[/code]

	
	I know it's a little clunky, but a table was ideal to show this information in the format required.
	
	Within the custom post types I have 2 categories and I wanted to be able to display each category on a separate page. The conditional statement chooses between the 2 categories for the required pages.
	
	
[code]add_action('pagelines_inside_bottom_theloop', 'boat_posts'); function boat_posts($query) { if ( is_page(70)) { $args = array( 'posts_per_page' => 10, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'portfolio', 'boatcategories' => 'nuevas', 'post_status' => 'publish', 'paged' => $paged ); // Create a new instance $second_query = new WP_Query($args); // The Loop while( $second_query->have_posts() ) : $second_query->the_post(); ?> <?php global $post; $custom = get_post_custom($post->ID); $boat_make = $custom["boat_make"][0]; $boat_model = $custom["boat_model"][0]; $boat_year = $custom["boat_year"][0]; $boat_length = $custom["boat_length"][0]; $boat_beam = $custom["boat_beam"][0]; $boat_fuel = $custom["boat_fuel"][0]; $boat_water = $custom["boat_water"][0]; $boat_price = $custom["boat_price"][0]; ?> <div class="customloop-item"> <div style="float:left;"> " rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>"> <?php the_post_thumbnail(array(150, 150 ));?> </div> <div style="float:left;padding-left:40px;"> <h3>" rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>"><?php the_title(); ?></h3> <table style="border:0;"> <tr> <td width="100" align="right">Año : </td> <td width="100" align="right"><?php echo $boat_year; ?></td> <td align="left"></td> </tr> <tr> <td align="right">Eslora : </td> <td align="right"><?php echo $boat_length; ?></td> <td align="left"> M</td> </tr> <tr> <td align="right">Manga : </td> <td align="right"><?php echo $boat_beam; ?></td> <td align="left"> M</td> </tr> <tr> <td align="right">Precio : </td> <td align="right"><?php echo $boat_price; ?></td> <td align="left"> €</td> </tr> </table> <p>" rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>">[ mas informacion ]</p> </div> </div>
<?php endwhile; wp_reset_postdata(); } elseif ( is_page(120)) { $args = array( 'posts_per_page' => 10, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'portfolio', 'boatcategories' => 'ocasion', 'post_status' => 'publish', 'paged' => $paged ); // Create a new instance $second_query = new WP_Query($args); // The Loop while( $second_query->have_posts() ) : $second_query->the_post(); ?> <?php global $post; $custom = get_post_custom($post->ID); $boat_make = $custom["boat_make"][0]; $boat_model = $custom["boat_model"][0]; $boat_year = $custom["boat_year"][0]; $boat_length = $custom["boat_length"][0]; $boat_beam = $custom["boat_beam"][0]; $boat_fuel = $custom["boat_fuel"][0]; $boat_water = $custom["boat_water"][0]; $boat_price = $custom["boat_price"][0]; ?> <div class="customloop-item"> <div style="float:left;"> " rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>"> <?php the_post_thumbnail(array(150, 150 ));?> </div> <div style="float:left;padding-left:40px;"> <h3>" rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>"><?php the_title(); ?></h3> <table style="border:0;"> <tr> <td width="100" align="right">Año : </td> <td width="100" align="right"><?php echo $boat_year; ?></td> <td align="left"></td> </tr> <tr> <td align="right">Eslora : </td> <td align="right"><?php echo $boat_length; ?></td> <td align="left"> M</td> </tr> <tr> <td align="right">Manga : </td> <td align="right"><?php echo $boat_beam; ?></td> <td align="left"> M</td> </tr> <tr> <td align="right">Precio : </td> <td align="right"><?php echo $boat_price; ?></td> <td align="left"> €</td> </tr> </table> <p>" rel="bookmark" title="<?php _e('Link To', 'pagelines');?> <?php the_title_attribute();?>">[ mas informacion ]</p> </div> </div>
<?php endwhile; wp_reset_postdata(); } }

Again this is a bit clunky and I'm sure I will refine it for the launch of the site. I just wanted to get the process working for the client. Rich

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hi, Ive jsut started to add custom post types to my test site using the Custom Post Types UI plugin and I noticed you have the same issue as I do. I have created a post type called Rumors and when I goto my test post the links URL looks like this and works. MySite.com/rumors/rumors-title As does yours but when I goto this URL MySite.com/rumors And do the same on your webiste http://mon956.djhands.com/portfolio We both get a 404, how do I set this to show a list of the posts from that Post type ? Thanks Danny

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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

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  
Followers 0