Support » Plugin: Page-list » How can I randomize list once a day

  • nostrome

    (@nostrome)


    Hello! Enjoyed your plugin. Big thanks to you. I have a question about randomization. How can I modify a plugin code to make it randomize pagelist once a day. For example I have 15 childs of one parent category and 15 childs of another. And I would like to display 10 childs from two parents once a day in random order.
    Can you help me with that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author webvitalii

    (@webvitaly)

    It is not possible to with Page-List plugin.

    You can try to create you custom loop with help of WP_Query

    Your params will be something like this:

    $query = new WP_Query(
    array(
    ‘post_type’ => ‘page’,
    ‘posts_per_page’ => 20,
    ‘post_parent__in’ => array( 5, 7 ),
    ‘orderby’ => ‘rand’,
    )
    );

    I did something like this with your plugin. But I cannot reach a goal to randomize once a day. I store IDs of parent category in session.

    
    $ids = array( "2494", "2768" );	
    $id = 0;
    if ( ! $id ){
    $key = array_rand( $ids, 1 );
    $id=$ids[$key];
    $_SESSION['main'] = $id;
    echo do_shortcode('[pagelist_ext child_of="'.$id.'" image_width="50" limit_content="100" image_height="50" sort_column="rand" number="10"]');
    		}
    	}
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.