GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   a little script help needed (https://gfy.com/showthread.php?t=1169434)

lollipopx 07-01-2015 08:10 PM

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>

johnny_r 07-02-2015 06:27 AM

Just add the following: 'category_name=yourCategorySlug'.
For example:
<?php $args = array( 'numberposts' => 42, 'orderby' => 'rand', 'category_name=blowjobs' );

That should do it ;)

lollipopx 07-02-2015 11:44 AM

Quote:

Originally Posted by johnny_r (Post 20513693)
Just add the following: 'category_name=yourCategorySlug'.
For example:
<?php $args = array( 'numberposts' => 42, 'orderby' => 'rand', 'category_name=blowjobs' );

That should do it ;)

Thanks. Seemed to almost work.
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

Venum 07-03-2015 12:37 AM

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

lollipopx 07-03-2015 10:38 AM

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.

lollipopx 07-03-2015 12:39 PM

Quote:

Originally Posted by Venum (Post 20514459)
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

Im doing something wrong here, I keep getting parse errors
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

Venum 07-03-2015 09:31 PM

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)

lollipopx 07-04-2015 12:50 PM

Quote:

Originally Posted by Venum (Post 20515286)
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)

Awesome, works good. thanks

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