• This may sound simple, but I cannot find anyone telling how to do it anywhere.

    I would like to have a single.php (which I have already coded, as well as I have the header.php, footer.php, content, etc) with the code for the header and footer ON THE ACTUAL single.php page (ie not get_header(); not get the <?php the_content(); ?> )

    However, how can I insert the code from header.php in the single.php? It begins with an html doc type and tag and then the head and things. I’ve tried several different ways to add this, but I think I need some actual explanation on what gets put in the single.php and where.

    Thanks,
    James

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you don’t want to use the get_header() etc functions then you’ll need to paste the actual HTML code into that template instead of the <?php get_header(); ?> tag.

    Why is it that you don’t want to use the standard built-in functions for this?

    Thread Starter JHaleavy

    (@jhaleavy)

    Hi, thanks.

    So how do I do that, for example, please?

    In my single.php I open the file with

    <?php
    /*
    ...
    */
    
    get_header();
    
    if (function_exists('add_theme_support')) {
      add_theme_support('post-thumbnails');
      set_post_thumbnail_size(150,150);

    etc…

    And then my header begins this way:

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    	<head>
    		<meta charset="<?php bloginfo('charset'); ?>">
    		<meta name="viewport" content="width=device-width">
    		<title><?php bloginfo('name'); ?></title>
    		<?php wp_head(); ?>
    		<script type="text/javascript"> var c = document.getElementById("article"); function resizeText(multiplier) { if (c.style.fontSize == "") { c.style.fontSize = "1.0em"; } c.style.fontSize = parseFloat(c.style.fontSize) + (multiplier * 0.2) + "em"; } </script> <script type="text/javascript"> jQuery(document).ready(function($) { $('.open-popup').click(function(e) { e.preventDefault(); window.open(this.href, '_blank', 'width=800,height=600'); }); }); }(jQuery)); }); </script>
            <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />
     </head>
    
    <body { height:100%} <?php body_class(); ?>>

    But how do I take what’s in the header.php and paste it into the single (like what do I remove. I can’t just replace the single.php’s <header> line with all the code from header.php — I must have to do something a little differently).

    In this case, I am trying to build an entire single-post layout on one page. I use the standard WordPress functions for most everything else. It’s complicated, but I’m working with internal css and things.

    I can’t just replace the single.php’s <header> line with all the code from header.php — I must have to do something a little differently).

    Yes, you can…

    <?php
    /*
    ...
    */
    
    // get_header();
    
    ?>
    PASTE EVERYTHNG FROM THE header.php FILE HERE!
    <?php
    
    if (function_exists('add_theme_support')) {
      add_theme_support('post-thumbnails');
      set_post_thumbnail_size(150,150);

    having said that, if you’re going to jsut use the same header as the rest of the site, there’s pretty much no point doing it this way, and for maintenance later on you’ll be better off leaving it with the get_header() call.

    Thread Starter JHaleavy

    (@jhaleavy)

    That worked absolutely. I feel kind of dumb but very thankful for explaining that.

    It’s also very interesting to see how WordPress works in a malleability sense. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to put header, content and footer in single.php file?’ is closed to new replies.