Notes on WordPress PHP

WordPress

Add this to the functions.php file in your theme folder. Taken from here.

<?php

 // Allow subscribers to see Private posts and pages

 $subRole = get_role( 'subscriber' ); 
 $subRole->add_cap( 'read_private_posts' );
 $subRole->add_cap( 'read_private_pages' );

Custom two-week calendar view using Google Calendar’s week view. Add this to a theme’s template file.

$mondayTime = strtotime('monday this week');
$startdate = date("Ymd", $mondayTime);
$enddate = date("Ymd", strtotime("+1 week"));

$cal = "<iframe src='LINK &amp;dates=$startdate/$enddate' style='border:solid 1px #777' width='95%' height='400px' frameborder='0' scrolling='no'></iframe>";
echo $cal;

$enddate2 = date("Ymd", strtotime("+2 weeks"));
$cal2 = "<iframe src='LINK &amp;dates=$enddate/$enddate2' style='border:solid 1px #777' width='95%' height='400px' frameborder='0' scrolling='no'></iframe>";
echo $cal2;

Leave a Reply

Your email address will not be published. Required fields are marked *