a little script help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lollipopx
    Confirmed User
    • Apr 2014
    • 171

    #1

    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>
    Lollipopx.com
    Twitter @lollipopx_1, Tumblr lollipop-x, ICQ 669068563, Skype lollipop_130 Tell me your from gfy or i might ignore you.
  • johnny_r
    Registered User
    • Aug 2014
    • 99

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

    That should do it ;)

    Adult-Wordpress-Theme.com

    Create Adult Tube sites based on Wordpress with Mass Video Embedder and Autopilot.
    $20 Discount code: GFY20

    Comment

    • lollipopx
      Confirmed User
      • Apr 2014
      • 171

      #3
      Originally posted by johnny_r
      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
      Lollipopx.com
      Twitter @lollipopx_1, Tumblr lollipop-x, ICQ 669068563, Skype lollipop_130 Tell me your from gfy or i might ignore you.

      Comment

      • Venum
        Confirmed User
        • Nov 2014
        • 182

        #4
        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

        Comment

        • lollipopx
          Confirmed User
          • Apr 2014
          • 171

          #5
          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.com
          Twitter @lollipopx_1, Tumblr lollipop-x, ICQ 669068563, Skype lollipop_130 Tell me your from gfy or i might ignore you.

          Comment

          • lollipopx
            Confirmed User
            • Apr 2014
            • 171

            #6
            Originally posted by Venum
            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
            Lollipopx.com
            Twitter @lollipopx_1, Tumblr lollipop-x, ICQ 669068563, Skype lollipop_130 Tell me your from gfy or i might ignore you.

            Comment

            • Venum
              Confirmed User
              • Nov 2014
              • 182

              #7
              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)

              Comment

              • lollipopx
                Confirmed User
                • Apr 2014
                • 171

                #8
                Originally posted by Venum
                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 ?
                Lollipopx.com
                Twitter @lollipopx_1, Tumblr lollipop-x, ICQ 669068563, Skype lollipop_130 Tell me your from gfy or i might ignore you.

                Comment

                Working...