Activity Stream
48,167 MEMBERS
6857 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member

    Default Difference between these two lines of code for Wordpress

    Code: 
     <?php $wp_query = new WP_Query( 'category_name=&posts_per_page='.get_option('posts_per_page'));
                     while ( $wp_query->have_posts() ) :  $wp_query->the_post();
                     
                     foreach((get_the_category()) as $category) {
                        $catname = $category->parent;
                        $cat_name = $category->name;
                        //$cat_parent= get_the_category_by_id( $catname);
                          $cat_id = $category->cat_ID;
                        if ($catname!=0)break;
                    }
                    
                    //echo $catname . ' - ' . $cat_name;
                    if(empty($catname)) $catname=$cat_id;
                     ?>
    That is the original code, I replaced (1)
    Code: 
    category_name=&posts_per_page='.get_option('posts_per_page')
    with (2)
    Code: 
    cat=-7&paged=' . $paged
    Now Wp-pagenavi works, but what are the consequences of that? What does (1) do, vs (2) ?

    Thanks in advance.
    LuDo8 Reviewed by LuDo8 on . Difference between these two lines of code for Wordpress <?php $wp_query = new WP_Query( 'category_name=&posts_per_page='.get_option('posts_per_page')); while ( $wp_query->have_posts() ) : $wp_query->the_post(); foreach((get_the_category()) as $category) { $catname = $category->parent; $cat_name = $category->name; //$cat_parent= get_the_category_by_id( $catname); $cat_id = $category->cat_ID; Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    show screen source?

  4.     
    #3
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    PHP Code: 
    category_name=&posts_per_page='.get_option('posts_per_page') 
    category_name is empty so that means it will grab from all categories
    posts_per_page = shows number of posts to show in each page

    While
    PHP Code: 
    cat=-7&paged=' . $paged 
    cat = categories seperated by id's to grab news of. Since you are using "-", it will show all other posts except from that category (7)
    paged = display the posts that would appear on x page!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help Me Please.. Code PHP Wordpress
    By fedro$a in forum Web Development Area
    Replies: 5
    Last Post: 27th Jun 2012, 12:11 PM
  2. Some Amazing English Lines
    By anaksr in forum General Discussion
    Replies: 3
    Last Post: 27th Jan 2012, 11:26 AM
  3. Help in replacing lines in various files
    By Funny in forum General Discussion
    Replies: 9
    Last Post: 19th Nov 2011, 08:16 PM
  4. tag code for wordpress
    By Majky71 in forum Wordpress
    Replies: 5
    Last Post: 2nd Oct 2011, 02:02 PM
  5. Wordpress code help
    By RT in forum Wordpress
    Replies: 1
    Last Post: 20th Dec 2009, 12:34 AM

Tags for this Thread

BE SOCIAL