Im presently attempting to adjust a Content SlideShow Wordpress plugin for Wordpress to be able to allow it to be suitable for WPML (Multilingual-Wordpress plugin). To do this, I must fetch the posts from the specific category, place them into an assortment and return that array. Wordpress_Query provides me with a difficult time carrying this out, because it appears like it's fetching the most recent publish infinite occasions informed. I am not familiar with writing Wordpress Plug ins, and so i could be grateful for just about any hint you are able to produce.

This is actually the code from the plug ins class method I am attempting to adjust.

    function get_valid_posts(){

    $validPosts = array();
    $this_post = array();
    $id_pot = array();

    $my_query = new WP_Query('cat=15&showposts=10');

    if($my_query->have_posts()) {
        while ($my_query->have_posts()) : 
            $post = $my_query->post;

            if(!in_array($post->ID, $id_pot)){
                $this_post['id'] = $post->ID;
                $this_post['post_content'] = $post->post_content;
                $this_post['post_title'] = $post->post_title;
                $this_post['guid'] = $post->guid;

                array_push($id_pot, $post->ID);
                array_push($validPosts, $this_post);

            }
        endwhile;
    }

    return $validPosts;
}

Observe that I have added the $id_pot array to be able to filter duplicate records, but this should not be necessary when the query / loop works.

Thanks ahead of time!

You're missing a phone call towards the function the_post();:

while ($my_query->have_posts()) : 
  $my_query->the_post();
  $post = $my_query->post;
  // ...
endwhile;

See The WordPress Loop

I have handled to resolve the issue:

    function get_valid_posts(){

    $validPosts = array();
    $this_post = array();
    $id_pot = array();
    $i = 0;

    $my_query = new WP_Query('category_name=gallery-post&showposts=10');

    if($my_query->have_posts()) {
        while($i < $my_query->post_count) : 
            $post = $my_query->posts;

            if(!in_array($post[$i]->ID, $id_pot)){
                $this_post['id'] = $post[$i]->ID;
                $this_post['post_content'] = $post[$i]->post_content;
                $this_post['post_title'] = $post[$i]->post_title;
                $this_post['guid'] = $post[$i]->guid;

                $id_pot[] = $post[$i]->ID;
                array_push($validPosts, $this_post);

            }

            $post = '';
            $i++;

        endwhile;
    }

    return $validPosts;
}

$my_query->post returns the information of the specific publish. Rather I needed to use $my_query->post*s* to obtain an assortment with the posts fetched being an object.