Custom Post type plugin is using theme single.php and style.css

I am trying to make a plugin for the display of recipes on my website. I registered a custom post type which works. I even created a file called template-single.php for the elements I want to display in the post. The I call it with get_template_part() in single-af_recipe.php. For some reason this isn’t working. My stylesheet for my plugin is also not working.

I tested this by putting the_title() in h4 tags. In the theme they are h1. I also made the h4 color red in af_style.css

Here are the files of my plugin:

I have a main file called recipe-maker.php where I include functions.php. Below I start from functions.php



add_action(‘init’, ‘af_recipe_post_type’);
add_action(‘wp_enqueue_scripts’, ‘af_enqueue_scripts’);
register_activation_hook( __FILE__, ‘af_pluginprefix_install’ );

//Enqueue styles
function af_enqueue_scripts() {
wp_enqueue_style(‘af_style’, plugins_url( ‘recipe-maker/af_style.css’, dirname(__FILE__) ) );

function af_pluginprefix_install() {
// clear the permalinks after the post type has been registered

//Register custom post type for recipes
function af_recipe_post_type() {
‘labels’ => array(
‘name’ => __(‘Recipes’),
‘singular’ => __(‘Recipe’),
‘public’ => true,
‘has_archive’ => true,
‘rewrite’ => array( ‘slug’ => ‘recipe’ ),
‘menu_icon’ => ‘dashicons-format-aside’,



<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<div class=”row”>

<div class=”single-post-title”>
<h4><?php the_title(); ?></h4>
<div class=”single-post-date”>
<h4><?php the_date(); ?></h4>
<?php the_content(); ?>



<div class=”wrapper”>
<div class=”container”>

<?php while ( have_posts()) : the_post(); ?>
<?php get_template_part(‘template-parts/template-single.php’); ?>
<?php endwhile; ?>


Read more here:: Custom Post type plugin is using theme single.php and style.css

Leave a Reply

Your email address will not be published. Required fields are marked *