• Resolved chrisbitz

    (@chrisbitz)


    I’m trying to get 3columns in the home page, and I found this solution from dodoland 7 months ago, but i’m not sure I understand how to implement the PHP in a child theme.

    I’ve got the CSS change working thanks to some help from Bojan, but I’m not sure how to put the index.php change in. Do I have to paste the whole function containing the line from index.php into functions.php in the child theme, or do I just put the relevant line in?
    The site is freyacat.co.uk/myctest

    <Begin quote>
    – in the CSS change the % in post-list class; now is 50%, for 3 columns will be 33%, for 4 25%, etc. –> .post-list .page { width: 33%; float: left; }
    <got this bit working>

    – in index.php (and obviously in archive and search) change the % in the line <?php if($i % 2 == 0) { echo ‘</div><div class=”post-row”>’; } $i++; endwhile; echo ‘</div>’; ?> –> 3 columns will be ($i % 3 == 0), 4 columns ($i % 4 == 0), etc.

    <end Quote>

    Thanks for any help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi chrisbitz. To implement the php change you would copy the index.php, and other files you want to change, from the parent theme folder to your child theme folder. Then,in the child theme, edit the file and find the line mentioned. Then just change the number after the % sign from 2 to 3. When you’re done that section of code would look like this:

    <div class="post-list group">
    	<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    		<?php get_template_part('content'); ?>
    	<?php if($i % 3 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    </div><!--/.post-list-->

    Hope that helps.

    Thread Starter chrisbitz

    (@chrisbitz)

    Thanks very much for the help – I’ve tried a number of different options, but I get various errors, and finally, I simply copied the entire index.php, and pasted it in child/functions with nothing else. I get this error:

    Fatal error: Call to undefined function ot_get_option() in /home/freyacat/public_html/myctest/wp-content/themes/hueman/header.php on line 42

    It may be strange, as the error references the original index.php, but I’m positive I’m editing the child index.PHP

    Also, both versions of index.php are only 35 lines long, yet the error’s in line 42?

    Maybe I have to define that I’m replacing index.php at the top of child/functions.php?

    Thanks again, Hope I’m not being dumb ??

    Thread Starter chrisbitz

    (@chrisbitz)

    I’ve done a bit of reading and searching, and it seems that the problem is that you cannot call Option tree – ot_get_option() in a child theme, without declaring or copying another function in advance or something…

    I can’t work out what other things I need to do though – any more clues guys?

    I can hard code it in index.php very easily, but that’s not how you learn, is it? ??

    Let’s back up a bit. You said you copied the entire index.php and pasted it into the child functions.php file. Is that really what you did? If so, you need to delete all that code in functions.php. Then copy the index.php file from the parent theme folder and put the entire file into your child theme folder. So, if you look in the editor in your child theme, it should list index.php. This is the file you would change as noted above.

    Thread Starter chrisbitz

    (@chrisbitz)

    Wonderful! Thanks very much. I’d misunderstood your original bit. I thought everything went in functions.php.

    thanks very much for your time!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘home page post-list 3 columns’ is closed to new replies.