Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    See the hierarchy: https://wphierarchy.com

    single.php is used unless there’s a single-cpt.php (where ‘cpt’ is the slug for the post type).

    Don’t directly edit your theme; all PHP work should be done in a child theme.

    Thread Starter eonelson48

    (@eonelson48)

    Thanks. I think I sort of understand that. Tell me if I’m on the right track:

    The beginning of my current single.php code is:

    <?php get_header(); ?>
    <div id="content">
    	<?php while (have_posts()) : the_post(); ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class('post-single'); ?>> 
    			<h1 class="post-title-single entry-title"><?php the_title(); ?></h1>
    			<?php get_template_part( 'content-postmeta' ); ?>
    			<div class="entry-content">
    				<?php the_content(); ?>

    My “new” post slug is “urlpost”

    so If I copy this single.php I can have one called single-urlslug.php and when I use that custom post it will look for and find it? and if it doesn’t it will use the single.php?

    As long as I have that new file in my child theme?

    Or am I missing something? I’m probably trying to simplify something that is a bit more complicated – but that is how I begin to understand.

    Thanks.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    not urlslug as in a post titled about using single-about.php (though that will work for that one post) but, assuming your post type has the slug “people”, single-people.php will be used to display a single post of the type people.

    Thread Starter eonelson48

    (@eonelson48)

    OK – Thanks. I’ll try that and get back to you. Always appreciate the patient assistance of people who have a better grasp than I do, yet I want to accomplish it all!

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

The topic ‘Editing post single template’ is closed to new replies.