icfriend
Forum Replies Created
-
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedI really haven’t been able to knock this out. Anybody out there have any examples or know how to select 16 specific posts and have them display randomly, while all other posts are unaffected?
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedThank you for this alchymyth. I’ve been working on it quite a bit today. This seems like the type of thing that if someone knows what they’re doing it takes 3 minutes, but for someone who doesn’t have the experience knocking code around it’s a challenge.
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedDropping this code in now makes the right number of posts per page appear and the “older posts” link on the bottom of the page is back, but it is still showing random posts from all of the categories, sometimes displaying the same post 4 or 5 times on the page.
<?php $args = array( 'orderby' => 'rand', 'post_status' => 'publish', ); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <?php endforeach; ?>I’m getting closer. I tried bringing in another loop after this one, but I can’t get anything that really works yet.
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedSo I’m trying to drop in the first code in the index.php file below:
<?php while (have_posts()) : the_post(); ?>I’ll have to tweek it quite a bit. I removed this section because I don’t know what it wants:
~Post-related code and template tags go here. ~The code I posted earlier is making everything completely random. All of the posts from all of the categories are random, sometimes displaying the same post 4 or 5 times on the page. It also shows a random number of posts on the page. It even removed the “older posts” link at the bottom.
I’ll need to search for “a regular query with a limit of 7” I don’t quite follow.
Thanks for your help!
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedAnother way to describe the problem that may make a solution easier. I have 23 posts from a category titled “Web Site”. I want the original seven to continue to show normally. But, out of the most recent 16, I only want one to display at a time.
I can’t even begin to wrap my mind around it, but I know from just looking at the .php I’ve seen that it has to be possible,. Out of everything I’ve tried, it must be the easiest solution.
Forum: Hacks
In reply to: One random post from 16 specific posts, but everything else unaffectedThe IDs don’t show up in the URL. Each post has it’s own slug, I.E = …./blog/2011/07/19/frame-episode-9/
…./blog/2011/06/18/new-leadership-keynote/
…./blog/2007/05/02/community-radio-licenses/Would it be something like this?
<?php $rand_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY RAND() LIMIT 1"); query_posts("p=$rand_id"); ?> <?php while (have_posts()) : the_post(); ?> ~Post-related code and template tags go here. ~ <?php endwhile; ?>