• Resolved zagreus

    (@zagreus)


    I’m building a plugin which has some custom templates for my custom post types. In my single- file, the code below shows the header, title and footer but for some reason doesn’t show the content.

    wp_enqueue_style('mjt_css', MJT_CLASS_CSS_URI.'/mjt.css');
    get_header();
    the_title();
    the_content();
    get_footer();
    ?>

    Here is the code creating the post type …

    $args = array(
                'labels'            => $labels,
                'public'            => true,
                'public_queryable'  => true,
                'exclude_from_search'   => false,
                'show_in_nav_menus'     => true,
                'show_ui'               => true,
                'show_in_menu'          => true,
                'show_in_admin_bar'     => true,
                'menu_position'         => 10,
                'menu_icon'             => 'dashicons-universal-access',
                'can_export'            => true,
                'delete_with_user'      => false,
                'hierarchical'          => false,
                'has_archive'           => true,
                'query_var'             => true,
                'capability_type'       => post,
                'map_meta_cap'          => true,
                //capabilities
                'rewrite'               => array (
                    'slug'          => 'trainer',
                    'with_front'    => true,
                    'pages'         => true,
                    'feeds'         => true
                ),
                'supports'              => array (
                    'title',
                    'editor',
                    'author',
                    'comments'
                )
    
            );
    
        register_post_type('mjt_trainer', $args);

    Any tricks here that I’m missing?

    Cheers …

    Z

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well based on that first code snippet, you don’t actually have The Loop anywhere (unless that’s in your header).

    You want:

    wp_enqueue_style('mjt_css', MJT_CLASS_CSS_URI.'/mjt.css');
    get_header();
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
    the_title();
    the_content();
    <?php endwhile; ?>
    <?php endif; ?>
    get_footer();

    (But really, that wp_enqueue_style shouldn’t be there. That should be in functions.php and properly hooked into the ‘wp_enqueue_scripts’ action.)

    Can’t say for sure that will fix the problem, but that’s a good start.

    Thread Starter zagreus

    (@zagreus)

    Thank you NoseGraze, that fixed it. Appreciate your help. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_content() not showing content in plugin’ is closed to new replies.