Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter RyanJenkins

    (@ryanjenkins)

    Great! That put the one large post at the top. And if I set several posts as sticky, they will appear below the top one in a row?

    Thread Starter RyanJenkins

    (@ryanjenkins)

    Fantastic, perfect, thanks a million.

    Thread Starter RyanJenkins

    (@ryanjenkins)

    That did not work. I am content, for now to leave it like this:

    if (is_page('36') ) {			// Larry Bostic		tag 30
    		  $tag = 'Larry Bostic';
    }
    
    ...
    
    $profiles->query("tag=$tag");

    Appreciate it. This page likely won’t be expanded too often, so it’s alright to keep doing it manually. I will mark as resolved. Ryan

    Thread Starter RyanJenkins

    (@ryanjenkins)

    Okay, so I got this:

    if (is_page('36') ) {			// Larry Bostic		tag 30
    $tag = 'Larry-Bostic';}
    
    ...
    
    $profiles->query("tag=$tag"); ?>

    And that works just fine. Before I go this route completely, is there a way to pass just the tag ID number? Again, I feel more comfortable passing numbers than strings. Thanks.

    Thread Starter RyanJenkins

    (@ryanjenkins)

    Now I am looking to do the same thing, except with tags instead of categories.

    Here is my code, largely adopted from this Codex page: http://codex.wordpress.org/Template_Tags/query_posts

    <?php
    		$tag = '';
    		if (is_page('36') ) {			// Larry Bostic		tag 30
    		  $tag = 30;
    		} elseif ( is_page('38') ) {	// Orlando Boquete	tag 31
    		  $tag = 31;
    		} elseif ( is_page('11') ) {	// Alan Crotzer		tag 32
    		  $tag = 32;
    		// ...etc...
    
    		echo($tag);
    
    		if ($tag) {
    		  $profiles = new WP_Query();
    		  $profiles->query("tag=$tag"); ?>
    		  <ul> <!-- Put an if statement to have a header "Related news items about $title..." -->
    		     <?php while ($profiles->have_posts()) : $profiles->the_post(); ?>
    		     <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    		    <?php endwhile; ?>
    		  </ul>
    	<?php }  ?>

    The problem is that I can’t find an example of query being run and using only the tag ID number. This is a bit easier, I think, but I could just as quickly use a string that’s the actual tag’s name. So, instead of using $tag = 30; for Larry Bostic, using$tag = ‘Larry Bostic’`.

    First, is there a way just to do this using the tag ID, which I think is more reliable/trustworthy than using the actual string? If there’s not, then I’d like an example of using the syntax to define $tag, and then passing it or using it to query.

    Thanks!

    Thread Starter RyanJenkins

    (@ryanjenkins)

    Oh, also, it wasn’t filtering categories correctly when I first implemented it and I had to figure out why. Here is why. On this line:

    $profiles->query("showposts=5&amp;cat=$cat"); ?>

    I had to change the &amp; to an actual ampersand (&amp;). This might have been the fault of the browser you were using to post or something. Just FYI.

    Edit: my browser just did it, too. Maybe it is the fault of WP’s forums.

    Thread Starter RyanJenkins

    (@ryanjenkins)

    Excellent, thanks for the code. I modified it a little to fit my needs, and it’s looking great. I just put a mini-version on my Press Releases page to pull from that category, and it works just fine. Now I get to have fun formatting the output. I’ll be back here if I run into problems with the full deployment in a day or two. Thanks again! Ryan

    Thread Starter RyanJenkins

    (@ryanjenkins)

    So, since I have several different pages that will require different categories of posts be loaded, will that template have a big if/else structure like this in it, one that is manually maintained? I took this example off of the page you sent:

    <?php
    if (is_page('21') ) {
    $cat = array(12);
    } elseif ( is_page('16') ) {
    $cat = array(32);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } else {
    $cat = '';
    }

    “A Page of Posts,” I think that’s right. Although, I’m going to have to have two loops there, I’m going to have to have the loop that displays the regular the_content or the_post from that page, and then also generates this little list off to the side… Am I on the right track? Thanks for the info.

    Thread Starter RyanJenkins

    (@ryanjenkins)

    I had to jigger the if/else syntax, because I am new to PHP, but it worked.

    Fantastic, resolved, done. Thanks!

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