Tag:get_posts

  • The use of the WordPress get_posts function prohibits the output of articles of a specified category

    Time:2019-7-26

    Using WordPress to prohibit the output of a specified category, you can pass an array parameter to the get_posts() function, as follows: Copy code The code is as follows: <div><h3> Random presentation</h3> <ul> <?php $args=array( ‘numberposts’=>16, ‘category’=>’-9,-12′, ‘orderby’=>’rand’ ); $rand_posts = get_posts($args); foreach( $rand_posts as $post ) : ?> <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li> […]