0

I'm working on a website with a portfolio section, and I'm almost finished with this section, but I have a problem with the single page which is :

  • whenever i click on any portfolio link, the single page opens but not showing any details except the previous and next link and this works correct.
  • Also it uses the single.php and I can't change it.

Taking in consideration my main post link is (our-portfolio) and the custom post (slug = portfolio).

I tried this step:

  • I have created a new single page with name (single-portfolio.php) and put it in the same place where my ( single.php) is but not working.

UPDATE

my Custom Post args:

$args = array(
    'labels' => $labels,
    'public' => true,
    'menu_icon'=> 'dashicons-groups',
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array('slug' => 'portfolio', 'with_front' => true),
    'query_var' => true,
    'show_in_nav_menus'=> false,
    'exclude_from_search' => true,
    'supports' => array('title', 'excerpt', 'page-attributes')
);

    register_post_type( 'port', $args );

I hope I haven't missed anything.

3
  • Please show your CPT registration arguments.
    – Rarst
    Apr 20, 2014 at 12:15
  • register_post_type( '???', $args ); ? Apr 20, 2014 at 12:25
  • register_post_type( 'port', $args ); Apr 20, 2014 at 12:31

1 Answer 1

1

Your code looks sound, so you should have a look at the code in your single.php template, as I suspect that there is something wrong in that template to why nothing is displayed. You should set debug to true in wp-config.php. This should help you locate your problem

Secondly, your single-posttype.php is wrongly named. Your post type is registered as "port", and you are using "portfolio". You should name your single page template the same as your registered post type. So you single template should be names single-port.php

Just for extra info, here is a small trick to force a template for use by a custom post type

function wpse_template_include( $original_template ) {
    if ( isset( $wp->query_vars['port'] ) && false == $wp->query_vars['port']  ) {
        return get_template_directory() . '/single-port.php';
    } else {
        return $original_template;
    }
}

add_filter( 'template_include', 'wpse_template_include' );
3
  • Secondly part works, now i can use single-port.php but as i said before not showing any details except the previous and next link and this works correct. Apr 20, 2014 at 12:46
  • Add the code of your single-port.php to your question Apr 20, 2014 at 12:53
  • The page now working but i will create custom fields to test that i can display the value in single-port.php. Apr 20, 2014 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.