• Resolved labyrinthman

    (@labyrinthman)


    I’m trying to loop through all the posts but I’m only getting 12 posts.

    
        $args = array('post_type' => 'post');  
        $loop = new WP_Query($args);
    
    if($loop->have_posts() ) :
        while ( $loop->have_posts() ) : $loop->the_post();  
        $title = get_the_title();
        $post_category=get_the_category();
        $post_category_name=$post_category[0]->cat_name;
        $permalink=get_the_permalink();
    
        $lng=get_post_meta( get_the_ID(), 'lng', TRUE ); 
        $lat=get_post_meta( get_the_ID(), 'lat', TRUE ); 
    
        $beer = get_post_meta( get_the_ID(), 'price_beer', TRUE );
        $wine = get_post_meta( get_the_ID(), 'price_wine', TRUE );
        $lnglat=$lng.", ".$lat; 
    
        
        $arrlatlng[]=array(
            "lnglat"=>$lnglat,
            "beer"  =>$beer,
            "wine"  =>$wine,
            "post_title"=>$title,
            'post_category'=>$post_category_name,
            'post_url'=>$permalink);
        $longitude[]=array('lng'=>$lng);
        $latitude[]=array('lat'=>$lat); 
        endwhile; 
        
          endif;
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    In your $args, how many posts are you asking for? Did you set a value of -1 for posts_per_page?

    • This reply was modified 7 years, 3 months ago by bcworkz. Reason: typo
    Thread Starter labyrinthman

    (@labyrinthman)

    @sterndata

    Thank you Steven Stern, that solved the problem.
    Here is the updated version of $args variable with your code.

    $args = array('post_type' => 'post','posts_per_page' => -1);

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Best way to insert post attributes into array?’ is closed to new replies.