Welcome! To use this support forum, please Login or Join Today!

   

Formatting custom posts the sames as pages

{name}
RankRank

Total Posts: 43

Joined 2011-05-19

PM

 

I would like to display single custom posts in the same way as pages. Is it possible to add the Template selection that Pages have to a Custom Post type? Specifically I want my custom posts to have no sidebar, no breadcrumbs and no meta.

The custom post type is called “areas”. I’ve created a single-areas.php template containing the same content as the onecolumn-page.php but still get a sidebar and breadcrumb. I’d guess I have to add the new custom post type to your formatting funcion in functions.php but you put that big warning up over it!

Any tips?

cheers
Nick

{name}
RankRank

Total Posts: 43

Joined 2011-05-19

PM

 

I think I’ve got an answer. I edited functions.php as follows:

function st_layoutstyle() {
global $post;
$layoutstyle = get_post_meta($post->ID, “st_layout_box”, $single = true);
$theme_defaults = of_get_option(‘page_layout’);

if (is_single() || is_page() ||  ‘areas’ == get_post_type() ) {
 
  // make sure no widgets are active
  if (
  is_single() && !is_active_sidebar(‘primary-widget-area’)  && $layoutstyle != ‘wide’ ||
  is_page() && !is_active_sidebar(‘secondary-widget-area’) ||
      is_single() && ‘areas’ == get_post_type() ||
      is_single() && ‘materials’ == get_post_type()

      ){ .....

Then to get the admin page working I installed Custom Post Templates plugin, then added this

/**
 * Hooks the WP cpt_post_types filter 
 *
 * @param array $post_types An array of post type names that the templates be used by
 * @return array The array of post type names that the templates be used by
 **/
function my_cpt_post_types$post_types {
    $post_types[] 
'areas';
    return 
$post_types;
}
add_filter
'cpt_post_types''my_cpt_post_types' ); 

to functions.php, and created single-areas.php to have the same content as the onecolumn template.

Is there any more elegant way of doing this?

cheers
Nick

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

Without doing much extensive testing, I’d say that would be the the simplest way. If using the child theme, also try copying the “st_content_wrap” function into your child theme and add your condition there as well - in order to ensure the sixteen columns div gets rendered and everything remains valid and responsive.

{name}
RankRank

Total Posts: 43

Joined 2011-05-19

PM

 

Thanks Casey