WordPress.org

Ready to get started?Download WordPress

Forums

Reverse-installing blog functionality (3 posts)

  1. drummerboy
    Member
    Posted 6 months ago #

    Hey everyone,

    So I made a wordpress site for a friend in 2011 and while it works fine perhaps it is not the best example of coding (i'm a designer primarily). There are lots of template files for pages and a few hard-coded bits in those templates. Thats all I was capable of doing at the time and it worked. He didn't want a blog at the time so I (perhaps foolishly) deleted all the other files in the theme except the ones the site was using.

    Now, in 2014, he wants to add a blog. The trouble is the way I built the original site with the wordpress vesion at the time and the way the latest version of wordpress works seems quite different. I have tried copying across all the missing theme files from the twentyfourteen theme and trying to compare my versions of index.php etc, copy and pasting code, but I think this is potentially asking for trouble! We will re-do the whole site in a year or so most likely using a premium base theme so at present we just need a working blog page.

    Does anyone have any advice on the best way to go about this, or if its even doable?

    My alternative plan is make a sub-domain on the site with another install of wordpress just to host a blog. Is that wise? Especially from an SEO point of view?

    Any information will be gratefully received!

    thanks in advance :)

  2. alchymyth
    Forum Moderator
    Posted 6 months ago #

    tried copying across all the missing theme files from the twentyfourteen theme

    it should be enough to add an index.php or home.php ( http://codex.wordpress.org/Template_Hierarchy#Home_Page_display ) file with a loop, and then set either the front page or any other page as the 'posts page'; http://codex.wordpress.org/Creating_a_Static_Front_Page

    does your theme have an index.php?
    what is the code of that?

  3. drummerboy
    Member
    Posted 6 months ago #

    I've tried adding the home.php but it doesn't seem to do anything.

    The index.php of my theme is as follows:

    <?php
    /**
     * @package WordPress
     * @subpackage Emotion Studios
     */
    
    get_header(); ?>
    
    <div id="page-wrapper">
    
        <?php if (have_posts()) : ?>
    
                <?php while (have_posts()) : the_post(); ?>
    
                <?php if ( is_front_page() ) { ?>
    
                <!-- homepage layout code goes here -->
    
                <?php the_content('Read the rest of this entry &raquo;'); ?>
    
                <div id="main">
    
                <?php } else { ?>
    
                <!-- default page layout code goes here -->
    
                <!-- this is secondary navigation code for sub-pages within a section -->
    
                <?php
                if($post->post_parent)
                $children = wp_list_pages("exclude=100,101,102,311,318,315&title_li=&child_of=".$post->post_parent."&echo=0");
                else
                $children = wp_list_pages("exclude=100,101,102,311,318,315&title_li=&child_of=".$post->ID."&echo=0");
                if ($children) { ?>
    
                <div id="main">
    
                <?php the_content('Read the rest of this entry &raquo;'); ?>
    
                <div id="column2">
                	<h2>Buy an Emotion Studios Shoot</h2>
                    <img class="shoot" src="http://www.emotionstudios.co.uk/wordpress/wp-content/themes/emotion/images/buy-emo.jpg" alt="Emotion Studios" />
                    <p>If you would like to book a photoshoot you can make a secure payment using the PayPal button below.</p>
                    <a href="http://www.emotionstudios.co.uk/photography-shoots/buy-a-shoot/"><img class="buy" src="http://www.emotionstudios.co.uk/wordpress/wp-content/themes/emotion/images/pay-pal-btn.png" alt="Buy Now" description="#" /></a>
                    <br />
    				<h6 class="dashed-divider"></h6>
    				<h2>Call us now to book your shoot</h2>
    				<h2 class="call"><a href="callto:01746 710 128">+44 (0) 1746 710 128</a></h2>
    				<h6 class="dashed-divider"></h6>
    				<h2>Testimonials</h2>
    					<?php get_sidebar( 'content' ); ?>
    
    			</div>
    
                </div>
    
                <?php } else { ?>
    
                <div class="main">
    
                <?php the_content('Read the rest of this entry &raquo;'); ?>
    
                <div id="column2">
                	<h2>Buy an Emotion Studios Shoot</h2>
                    <img class="shoot" src="http://www.emotionstudios.co.uk/wordpress/wp-content/themes/emotion/images/buy-emo.jpg" alt="Emotion Studios" />
                    <p>If you would like to book a photoshoot you can make a secure payment using the PayPal button below.</p>
                    <a href="http://www.emotionstudios.co.uk/photography-shoots/buy-a-shoot/"><img class="buy" src="http://www.emotionstudios.co.uk/wordpress/wp-content/themes/emotion/images/pay-pal-btn.png" alt="Buy Now" description="#" /></a>
    				<h6 class="dashed-divider"></h6>
    				<h2>Call us now to book your shoot</h2>
    				<h2 class="call"><a href="callto:01746 710 128">+44 (0) 1746 710 128</a></h2>
    				<h6 class="dashed-divider"></h6>
    				<h2>Testimonials</h2>
    					<?php get_sidebar( 'content' ); ?>
    
    			</div>
    
                </div>
    
                <?php } ?>
    
                <?php } ?>
    
                <?php endwhile; ?>
    
        <?php else : ?>
    
                <h1>Oops!</h1>
                <p>We couldn't find the page you're looking for. Why not start again at the <a href="/">homepage</a>.</p>
    
        <?php endif; ?>
    
        	</div><!-- close page wrapper -->
    
            </div><!-- close main -->
    
    <?php get_footer(); ?>

    and the home.php is as follows:

    <?php
    /**
     * @package WordPress
     * @subpackage Emotion Studios
    
     */
    
    get_header(); ?>
    
    <div id="page-wrapper">
    
    <?php
    	if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
    		// Include the featured content template.
    		get_template_part( 'featured-content' );
    	}
    ?>
    
    	 <div id="main">
    
    		<?php
    			if ( have_posts() ) :
    				// Start the Loop.
    				while ( have_posts() ) : the_post();
    
    					/*
    					 * Include the post format-specific template for the content. If you want to
    					 * use this in a child theme, then include a file called called content-___.php
    					 * (where ___ is the post format) and that will be used instead.
    					 */
    					get_template_part( 'content', get_post_format() );
    
    				endwhile;
    				// Previous/next post navigation.
    				twentyfourteen_paging_nav();
    
    			else :
    				// If no content, include the "No posts found" template.
    				get_template_part( 'content', 'none' );
    
    			endif;
    		?>
    
    		</div><!-- #main -->
    	<?php get_sidebar( 'content' ); ?>
    	</div><!-- #page wrapper -->
    
    <?php
    get_footer();?>

    I have a static page 'Blog' assigned as the blog page, but it is just using the default template at the moment.

    Is there anything glaringly wrong with the code?

Reply

You must log in to post.

About this Topic