SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    wordpress get_post_meta with query_post() function

    Hello forums

    Is it possible to get custom fields data using the query_post() function of wordpress? I have this:

    PHP Code:
    query_posts('category_name=videos');
     while (
    have_posts()) : the_post();
     echo 
    get_post_meta($post->ID'videoThumb'true);
     endwhile; 
    But nothing happens. When I echo $post->ID the string is null.

    Any ideas? Thanks
    Don't Panic

  2. #2
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind it can't be done, I use WP_Query instead and globalize $post


    PHP Code:
    $my_query = new WP_Query('cat=4');
      while (
    $my_query->have_posts()) : $my_query->the_post();
        global 
    $post
        echo 
    get_post_meta($post->ID'videoThumb'true);

     endwhile; 
    Cheers!!
    Don't Panic

  3. #3
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    589
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry Never should have spoken too soon, correction it CAN be done just globalize $post

    PHP Code:
    query_posts('category_name=videos');

     while (
    have_posts()) : the_post();
    global 
    $post;

     echo 
    get_post_meta($post->ID'videoThumb'true);

     endwhile; 
    Cheers
    Don't Panic


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •