• Resolved marv2

    (@marv2)


    Hi, I created a custom post type and custom taxonomies as well as custom meta fields, by hardcoding them to my child functions.php file.

    I would like to create a custom post type template so I can display my taxonomies and meta data on the post page, but I noticed this theme does not have a single.php file to copy to single-{post_type}.php.

    Which file would I have to edit in order to do something like this? I do not wish to use the toolset plugin.

    Thanks for a great theme!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Theme Author oceanwp

    (@oceanwp)

    Hello, you can use the singular.php file.

    Thread Starter marv2

    (@marv2)

    Thank you. Which parts of it can I safely delete if I want to insert my own content in the main content area? I don’t want to mess anything else up.

    Also, is it possible to make a custom header for just this post type?

    Thanks!

    Theme Author oceanwp

    (@oceanwp)

    Hello, if you will create a custom query, you can remove:

    // Start loop
    while ( have_posts() ) : the_post();
    
    		// EDD Page
    		if ( is_singular( 'download') ) {
    			get_template_part( 'partials/edd/single' );
    		}
    
    		// Single Page
    		elseif ( is_singular( 'page' ) ) {
    
    			get_template_part( 'partials/page/layout' );
    
    		}
    
    		// Library post types
    		elseif ( is_singular( 'oceanwp_library' )
    				|| is_singular( 'elementor_library' ) ) {
    
    			get_template_part( 'partials/library/layout' );
    
    		}
    
    		// All other post types.
    		else {
    
    			get_template_part( 'partials/single/layout', get_post_type() );
    
    			}
    
    endwhile;

    For the header, you can use this function: https://docs.oceanwp.org/article/375-altering-header-style-by-page
    Replace “is_front_page()” by your single CPT function.

    Thread Starter marv2

    (@marv2)

    Thanks that was a great help!

    One last thing, how would I change the page background color on thte custom post type page?

    Theme Author oceanwp

    (@oceanwp)

    Hello, send me a link of your CPT page.

    Thread Starter marv2

    (@marv2)

    Hi, it is not live yet.

    Theme Author oceanwp

    (@oceanwp)

    Hi, I need some specific css selectors to change the background only for your CPT page.

    Thread Starter marv2

    (@marv2)

    Hello, if you will create a custom query, you can remove:

    // Start loop
    while ( have_posts() ) : the_post();

    // EDD Page
    if ( is_singular( ‘download’) ) {
    get_template_part( ‘partials/edd/single’ );
    }

    // Single Page
    elseif ( is_singular( ‘page’ ) ) {

    get_template_part( ‘partials/page/layout’ );

    }

    // Library post types
    elseif ( is_singular( ‘oceanwp_library’ )
    || is_singular( ‘elementor_library’ ) ) {

    get_template_part( ‘partials/library/layout’ );

    }

    // All other post types.
    else {

    get_template_part( ‘partials/single/layout’, get_post_type() );

    }

    endwhile;

    Hi, will this work if i want to put a custom div on the page instead of a custom loop? I have a div that I designed that displays all the data I want. Also, will the page still be responsive if I put in the div?

    Theme Author oceanwp

    (@oceanwp)

    Hello, you mean for the background of the page? No, it is only via the body tag.

    Thread Starter marv2

    (@marv2)

    Hi, I would like to create a custom header for my custom post type page. What files do I have to modify to do that?

    Thanks!

    Theme Author oceanwp

    (@oceanwp)

    Hello, if you use Elementor, I would recommend you Elementor Pro to do this, they have a feature to assign a custom header to any CPT.

    Thread Starter marv2

    (@marv2)

    Thanks for the reply, but I would like to do it in code. Can you please advise me which files I have to edit? Thanks!

    Thread Starter marv2

    (@marv2)

    I would like to change the post title area in the header. I want to put a full width background image there and some taxonomy data. I want the title area of the header to look something like this, with my own image in the background: Title Header Area

    Theme Author oceanwp

    (@oceanwp)

    Hello, sorry, right now, it is not possible to display a custom header style only for a CPT.

    Thread Starter marv2

    (@marv2)

    Thanks. What about for all posts?

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘How to create a custom post type template’ is closed to new replies.