Skip to content

Instantly share code, notes, and snippets.

View KorvinM's full-sized avatar
🏠
Working from home

Korvin KorvinM

🏠
Working from home
View GitHub Profile
@KorvinM
KorvinM / daily-god.php
Last active June 4, 2020 12:34
PHP to output a daily god.
<?php
$today = getdate();
$dayOfWeek = $today['weekday'];
$godsOfDay = [
'Monday' => 'mani',
'Tuesday' => 'tyr',
'Wednesday' => 'odin',
'Thursday' => 'thor',
'Friday' => 'frigg',
@KorvinM
KorvinM / wp-supress-private-posts.php
Last active June 25, 2022 15:20
WordPress: Remove private posts from the main query on the posts page
<?php
/* We can use the pre_get_posts action hook to modify a query before it's run.
* http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts*/
add_action( 'pre_get_posts', 'kvn_rem_pp' );
function kvn_rem_pp($query){
if(current_user_can ('read_private_posts') ){
/*restrict to the posts page main query.
*All other views (eg. category archives) unnaffected
*http://codex.wordpress.org/Function_Reference/is_home
*http://codex.wordpress.org/Function_Reference/is_main_query*/