• Resolved sevennine

    (@sevennine)


    I’m using Ultimate Tag Warrior plugin (or at least trying to) and I’ve got it displaying posts in a certain tag, the questions I ask are:

    1) I’m haivng trouble calling the $post variable in THE LOOP, as int print_r($post) doesn’t print out anything, shouldn’t it printout the $post’s variables?

    2) is it possible to us the “query_posts” function call and call posts that containt certain tags?

Viewing 6 replies - 1 through 6 (of 6 total)
  • 1) If this is in a plugin, are you scoping $post to global, as in:

    global $post;

    This would (naturally) occur before making use of $post in your code.

    2) Tags are not considered a built-in WP component which relates to the posts table, so it would be difficult (if not impossible) to make use of query_posts for something like this.

    You wouldn’t be able to use query_posts, but you could do something like this to get the IDs of posts with certain tags:

    global $tablepost2tag;
    $wpdb->get_results( "SELECT post_id FROM $tablepost2tag WHERE tag_id = $tag" );

    It’s not much, since I’ve not had to do anything like #2, but it should get you started.

    Thread Starter sevennine

    (@sevennine)

    you would think that wouldn’t you? but the following only produces a list of the titles, am I missing something here? Shouldn’t it produce the title and the post’s details?

    <?php
    if (have_posts()) :
    while (have_posts()) : the_post();
    the_title();
    print_r($post);
    endwhile;
    endif;
    ?>

    Question is, where do you have this code running? It works (as expected) when I dump it into my theme’s index.php.

    Thread Starter sevennine

    (@sevennine)

    its running in TAG.PHP and is called when the tag archive is called for the Ultimate Tag Warrior plugin

    Thread Starter sevennine

    (@sevennine)

    got some reason $post wasn’t globally called, just added
    global $post;
    and it was all good

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘$post variable in a tag archive (UTW)’ is closed to new replies.