• Hi!
    I am working on a client website that was designed (I think from scratch) by another company and they didn’t include a single.php or archive.php template.

    I have a plugin where I can design specific templates for Single Posts and it works well, however it places its content into the single.php template, which this site doesn’t have.

    Can anyone recommend a sample single.php template I can download and install into this site so it at least has one. I did have a look at some articles but I think may be getting into more detail than I need?

    I’m unsure, as every other site I have worked on had a single and archive template as part of the original install.

    This image is the listing of the files under :
    /wp-content/themes/theme1

    https://ibb.co/Wxs1VgJ

    Ernie

Viewing 6 replies - 1 through 6 (of 6 total)
  • You shouldn’t need a single.php template. Most themes I’ve worked with don’t have one unless it’s a woocommerce site in which case you’ll want to ask the woocommerce support community

    https://woocommerce.com/contact-us/
    https://www.ads-software.com/support/plugin/woocommerce/

    Moderator bcworkz

    (@bcworkz)

    Your theme doesn’t need single.php, that much is evident since it’s working now without. I think you are saying your plugin requires it. Your theme has an index.php template in the theme folder. Copy that and rename it single.php. I think you will find index.php is currently used for single posts anyway.

    You may not really need a plugin to do custom post templates. Just name the template following the format “single-post-{$slug}.php” and that template will be used for the post with the corresponding slug. Once again, you can start with an index.php copy and just rename it. That plugin probably offers more flexibility though.

    For more on template naming and hierarchy, see https://developer.www.ads-software.com/themes/basics/template-hierarchy/

    Thread Starter esugrue

    (@esugrue)

    Hmm, OK thanks for that I probably misunderstood the theme author as he said:
    ‘The plugin should follow your original post logic. The content of our templates are placed in the container of the original post template.’

    Davood – thanks for the hint – it’s not WC, so I should be good.

    The site never had `posts’ as such and now they want a blog – anything entered as a post just showed the content – no date, author, category etc as most posts show!

    The plugin helps with that adding those meta fields, however the rest of the site is centred (like a boxed display) but now the post is flush left!

    I thought I needed a single.php to control the display (but it seems not, thank you for the clarification).

    My index.php is this:

    <?php get_header();?>
    <?php while ( have_posts() ) : the_post(); ?>
    <div class="body">
    	<div class="container">
    		<div class="clear"></div>
    		<div class="main">
    			<div class="post content">
    				<h1 class="page-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h1>
    
    				<div class="content">
    					<?php the_content(); ?>
    				</div>
    			</div>
    		</div>
    		<div class="clear"></div>
    	</div>
    </div>
    <?php endwhile; ?>
    <?php get_footer();?>

    So bcworkz – you think (know) I could copy this file, rename to single.php – and I should be able to edit it to centre the post content!

    • This reply was modified 5 years, 7 months ago by esugrue.

    I’m not bcworkz but I can definitely tell you that if you copy index.php and rename it to single.php then modify it to show the content you wish to show on you blog posts.

    Hope this helps. Please tag the thread as resolved once you figure out how to accomplish what you’re attempting to accomplish.

    Thread Starter esugrue

    (@esugrue)

    Thanks Davood – it helps more than you know, starting to get my head around it and understand it a bit better.

    Thanks

    Once I get it right and sorted – and have no more silly questions – I’ll mark it as resolved.

    no questions are silly.
    we are here to help! feel free to ask any questions you have about child themes!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create new, basic single.php template’ is closed to new replies.