Order users by random not working?

Ok, so I found this solution in other thread which did worked: Added this to functions.php: add_action( “pre_user_query”, function( $query ) { if( “rand” == $query->query_vars[“orderby”] ) { $query->query_orderby = str_replace( “user_login”, “RAND()”, $query->query_orderby ); } }); It sorts users by a random order now!

Display just one post from a loop of 5 posts?

Solved the problem by inserting this: <?php if (in_array($counter, array(0)) ) :?> // show content <?php $counter++; endif;?> The above basically displays only 1 post that is first in the array. In case anyone needs to solve a problem like this.

Create an array with all the links of the years’ archive (of a custom post type)

I just recieved this answer in the StackOF page and it worked, though I don’t fully understand it. $links = wp_get_archives(array(‘echo’=>’0′,’format’=>'<link>’)); $regex = ‘/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i’; preg_match_all($regex, $links, $matches); $array_links = $matches[0]; print_r($array_links); Just added ‘post_type’ => ‘myCPT’ in the wp_get_archives() array and it worked. Get to the real answer: https://stackoverflow.com/a/69365466/16825540

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)