Skip to main content
added 877 characters in body
Source Link
Krzysiek Dróżdż
  • 25.5k
  • 9
  • 53
  • 74

I want get all categor and after that i want get 5 post per category. but my code not work! http://pastebin.com/vxDSGGZk

<?php
    $categories=get_categories('');
    foreach($categories as $category) { 
        echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
        echo '<p> Cat ID: '. $category->cat_ID. '</p>';
    
        // The Query
        $id_cat = $category->cat_ID;}
        $args = array(
            'cat' =>  $id_cat,
            'posts_per_page' => 5,
        );
        query_posts( $args );
    
        // The Loop
        while ( have_posts() ) : the_post();
            echo '<li>';
            the_title();
            echo '</li>';
        endwhile;
    }
    
    // Reset Query
    wp_reset_query();
?>

please help me! thanks! P/s:this is the first time i ask on here and i can't paste code in here. please check link pastebin.

I want get all categor and after that i want get 5 post per category. but my code not work! http://pastebin.com/vxDSGGZk

please help me! thanks! P/s:this is the first time i ask on here and i can't paste code in here. please check link pastebin.

I want get all categor and after that i want get 5 post per category. but my code not work! http://pastebin.com/vxDSGGZk

<?php
    $categories=get_categories('');
    foreach($categories as $category) { 
        echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
        echo '<p> Cat ID: '. $category->cat_ID. '</p>';
    
        // The Query
        $id_cat = $category->cat_ID;}
        $args = array(
            'cat' =>  $id_cat,
            'posts_per_page' => 5,
        );
        query_posts( $args );
    
        // The Loop
        while ( have_posts() ) : the_post();
            echo '<li>';
            the_title();
            echo '</li>';
        endwhile;
    }
    
    // Reset Query
    wp_reset_query();
?>

please help me! thanks! P/s:this is the first time i ask on here and i can't paste code in here. please check link pastebin.

deleted 447 characters in body
Source Link

I want get all categor and after that i want get 5 post per category. but my code not work! http://pastebin.com/vxDSGGZk

<?php

$categories=get_categories(''); foreach($categories as $category) {please help me! thanks! echo '

Category

P/s: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all poststhis is the first time i ask on here and i can't paste code in %s" ), $category->name ) . '" ' . '>' . $category->name.'

'; echo '

Cat ID: 'here. $category->cat_IDplease check link pastebin. '

'; // The Query $id_cat = $category->cat_ID;} $args = array('cat' => $id_cat, 'posts_per_page' => 5, ); query_posts( $args );

// The Loop while ( have_posts() ) : the_post(); echo '

  • '; the_title(); echo '
  • '; endwhile; //}

    // Reset Query wp_reset_query(); ?>

    I want get all categor and after that i want get 5 post per category. but my code not work!

    <?php
    

    $categories=get_categories(''); foreach($categories as $category) { echo '

    Category

    : <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'

    '; echo '

    Cat ID: '. $category->cat_ID. '

    '; // The Query $id_cat = $category->cat_ID;} $args = array('cat' => $id_cat, 'posts_per_page' => 5, ); query_posts( $args );

    // The Loop while ( have_posts() ) : the_post(); echo '

  • '; the_title(); echo '
  • '; endwhile; //}

    // Reset Query wp_reset_query(); ?>

    I want get all categor and after that i want get 5 post per category. but my code not work! http://pastebin.com/vxDSGGZk

    please help me! thanks! P/s:this is the first time i ask on here and i can't paste code in here. please check link pastebin.

    Source Link

    Get post by Category in custom template

    I want get all categor and after that i want get 5 post per category. but my code not work!

    <?php
    

    $categories=get_categories(''); foreach($categories as $category) { echo '

    Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'

    '; echo '

    Cat ID: '. $category->cat_ID. '

    '; // The Query $id_cat = $category->cat_ID;} $args = array('cat' => $id_cat, 'posts_per_page' => 5, ); query_posts( $args );

    // The Loop while ( have_posts() ) : the_post(); echo '

  • '; the_title(); echo '
  • '; endwhile; //}

    // Reset Query wp_reset_query(); ?>