![]() |
a little script help needed
how to tell the following script to use specific categories and tags rather than random?
so it will display just the categories and tags i want it too. ie blowjobs, oral...etc.. <h2 class="post-title">Videos selected for you</h2> <?php $args = array( 'numberposts' => 42, 'orderby' => 'rand' ); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <div class="post" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(240,180), array('alt' => get_the_title(), 'title' => '')); ?></a> <?php if ( get_post_meta($post->ID, 'duration', true) ) : ?><div class="duration"><?php echo get_post_meta($post->ID, 'duration', true) ?></div><?php endif; ?> <div class="link"><a href="<?php the_permalink() ?>"><?php short_title('...', '34'); ?></a></div> <span>Added: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></span> <span><?php the_tags('Tags: ', ', ', ''); ?></span> </div> <?php endforeach; ?> <div class="clear"></div> |
Just add the following: 'category_name=yourCategorySlug'.
For example: <?php $args = array( 'numberposts' => 42, 'orderby' => 'rand', 'category_name=blowjobs' ); That should do it ;) |
Quote:
only it still pulls from all categories or something. The chosen categories show up more but not totaly. Is it possable to exclude categories and how would that be added? also can tags be used rathe than categories? or would that matter? Has not changed anything as far as on my mobile, no clue on whats up there. I would like for it to randomize selections from a couple specific categories and/or tags. not all |
For excluding categories, example:
'category__not_in' => array(catID, catID) For including categories, example: 'category__in' => array(catID, catID) For tags: tag__in & tag__not_in |
OK I'll give that a try.
How can I get it to randomize from the selected cats? I have been trying 'rand' in just about ever possible way but only randomizes all cats. |
Quote:
where exactly does it go? <?php $args = array( 'numberposts' => 42, 'orderby' => 'category_name=blowjobs');'category__not_in' => array(catID, catID); didnt work got parse error <?php $args = array( 'numberposts' => 42, 'orderby' => 'category__not_in' => array(catID, catID); didnt work got parse error what I have on now that works at displaying 1 cat but does not randomize it <?php $args = array( 'numberposts' => 42, 'orderby' => 'category_name=blowjobs'); for that I just replaced the 'orderby' => 'rand'); with the 'orderby' => 'category_name=blowjobs'); would like to add a few more categories and have it randomize them |
You have to replace catID with your category ID, example if your category ID for blowjobs is 43:
<?php $args = array( 'numberposts' => 42, 'orderby' => 'rand', 'category__in' => array(43) ); If you like to exclude category, then replace category__in to category__not_in. If you like to include or exclude multiple categories the you can but them like this: array(43, 56, 78) |
Quote:
As im sure your aware this is in side word press themes page php editor. so although its on each "Page" its not actualy "in" page if you follow me. How could I use this "in" page, say like so it can randomize to specific posts/cats like a featured post ? |
All times are GMT -7. The time now is 01:20 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123