• Resolved BiancavDam

    (@biancavdam)


    Hi,

    I’ve got these parts of the code for my index page which shows posts of a certain category. The problem is that I want the index to show all posts of EVERY category. My knowledge of PHP is not thát good so I figured I’d ask here. How can I adjust these parts of the code to make it work like that? 🙂

    <?php
         global $post;
         $myposts = get_posts('numberposts=3&category_name=Fashion');
         $x=0;
         foreach($myposts as $post) :
           setup_postdata($post);
         ?>
    $args = array(
                       'category_name' => 'Fashion',
                       'post_type' => 'post',
                       'posts_per_page' => 6,
                       'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                       );

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • try:

    <?php
         global $post;
         $myposts = get_posts('numberposts=3&cat=0');
         $x=0;
         foreach($myposts as $post) :
           setup_postdata($post);
         ?>

    (this is a zero in cat=0 )

    and:

    $args = array(
                       'cat' => 0,
                       'post_type' => 'post',
                       'posts_per_page' => 6,
                       'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                       );

    or try without 'cat' => 0,

    Thread Starter BiancavDam

    (@biancavdam)

    Thank for the help! Works! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add all categories in PHP code?’ is closed to new replies.