Ответы в темах

Просмотр 1 ответа (всего 1)
  • Нашел вот 2 кода, но первый выводит то же и в контенте, заместо главной, а второй выводит только список постов без категорий:

    <?php
                // get all the categories from the database
                $cats = get_categories();
    
                    // loop through the categries
                    foreach ($cats as $cat) {
                        // setup the cateogory ID
                        $cat_id= $cat->term_id;
                        // Make a header for the cateogry
                        echo "<strong>".$cat->name."</strong>";
    
                        // create a custom wordpress query
                        query_posts("cat=$cat_id&post_per_page=100");
                        // start the wordpress loop!
                        if (have_posts()) : while (have_posts()) : the_post(); ?>
    
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
        <?php } // done the foreach statement ?>

    и собственно второй код:

    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    <?php endwhile; ?>
Просмотр 1 ответа (всего 1)