1

I have created my custom post type plugin accurately & it is working perfectly on the admin panel.

I have set a filter to use custom template for this plugin

    add_filter( 'template_include', 'include_template_function', 1 );

function include_template_function( $template_path ) {
    if ( get_post_type() == 'employees' ) {
        // if ( is_single() ) {
            // checks if the file exists in the theme first,
            // otherwise serve the file from the plugin
            if ( $theme_file = locate_template( array ( 'employee-template.php' ) ) ) {
                $template_path = $theme_file;
            } else {
                $template_path = plugin_dir_path( __FILE__ ) . 'employee-template.php';
           // }
        }
    }
    return $template_path;
}

But I can't find the exact query by which I can show the custom fields contents on the website. I want a archive page but I will make it 3 columns. And I want to show custom fields content, not the body content.

  • By custom fields are you referring to custom post meta your custom post type contains? – Craig Harshbarger Jan 31 '16 at 0:35
0

What are your custom fields? As in, did you create custom fields using the built in way (under screen options > custom fields) or did you create custom fields in the theme customiser panel.

You need to make sure that the template "employee-template.php" is calling the custom fields. There are different ways to get the info from different methods of making custom fields... especially if you have created your own admin interface for theme customization as opposed to used built in wordpress methods.

Also make sure that you have in fact created employee-template.php and are not falling back on the template hierarchy.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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