WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Access WP Object from a query (3 posts)

  1. blirette
    Member
    Posted 3 years ago #

    Hey,

    I'd like to know how to access the object received from a query? I usually get an array, not an object from a query so I normally do this :

    $arrayValue['nameOfTheKindOfValue']

    How to do this with an object?

    Thanks, I'm sure it's pretty easy for you to answer.

  2. blirette
    Member
    Posted 3 years ago #

    $value = $post -> nameOfTheKindOfValue;

  3. blirette
    Member
    Posted 3 years ago #

    Or you could just use an array instead :

    $pageposts = $wpdb->get_results($strQuery, ARRAY_A);

    ... and be able to use it as an associative array instead of an object ...

    $pageposts = $wpdb->get_results($strQuery, OBJECT);

    More infos here : http://codex.wordpress.org/Function_Reference/wpdb_Class

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags