Размещение постов в 3 колонках

Есть тестовый сайт обоев. Мне необходимо разместить все посты в 3-ех или более колонках. Знаю что этот вопрос уже много где рассматривался, но у меня ничего не получилось. Вообще я только начал заниматься сайтами и много чего не знаю.
Вот код из index.php:
<?php

get_header(); ?>

<div id="primary">
<div id="content" role="main">

<?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( ‘content’, get_post_format() );
?>

<?php endwhile; ?>

<?php portfoliopress_content_nav(); ?>

<?php else : ?>
<?php get_template_part( ‘content’, ‘none’ ); ?>
<?php endif; ?>

</div><!– #content –>
</div><!– #primary –>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Посмотрите тут Sonika’s blog. В основном про WordPress » Посты в несколько колонок

И обязательно прочтите Иерархия шаблонов « WordPress Codex – чтобы потом не удивляться 😉

Спасибо, но я там уже смотрел. Там исходный код отличается от моего. Мне бы исправить именно в моем коде)

Если вы только начали заниматься сайтами, зачем вам WordPress?
Рисуйте на HTML и CSS. Затем изучайте основы PHP, а вот после — добро пожаловать.

Да , это я понимаю. Но сейчас мне нужно исправить мой начальный код, что бы посты в нем были в 3-ех колонках. Вот за этим я и обратился на форум, что бы мне помогли с этим.

Попробуйте вот так. Попробуйте почитать, что вам пишут. Ю. Б. дал ссылку на отличный пост от Sonika (http://www.sonika.ru/blog/wordpress/post-columns.htm)

<?php

get_header(); ?>

    <div id="primary">
        <div id="content" role="main">
           

<?php $col = 1; ?>
            <?php if ( have_posts() ) : ?>

                <?php /* Start the Loop */ ?>
                <?php while ( have_posts() ) : the_post(); ?>


<?php if ($col == 1) echo "<div class=\"row\">"; ?>
 <div class="post col<?php echo $col;?>" id="post-<?php the_ID(); ?>">

                    <?php
                        /* Include the Post-Format-specific template for the content.
                         * If you want to overload this in a child theme then include a file
                         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                         */
                        get_template_part( 'content', get_post_format() );
                    ?>



<?php if ($col == 1) echo "</div>"; (($col==1) ? $col=2 : $col=1); ?>

                <?php endwhile; ?>

                <?php portfoliopress_content_nav(); ?>
               
            <?php else : ?>
                <?php get_template_part( 'content', 'none' ); ?>
            <?php endif; ?>

            </div><!-- #content -->
        </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

В в style.css своей Темы:

.row { clear: both; }
.col1 { width: 200px; float: left; padding: 0 10px; }
.col2 { width: 200px; float: right;  padding: 0 10px; }

Куда именно в style.css вставлять вот это:
.row { clear: both; }
.col1 { width: 200px; float: left; padding: 0 10px; }
.col2 { width: 200px; float: right; padding: 0 10px; }

в любое удобное для вас место. Это не имеет значения.

Anonymous
Отправить
Ответ на: