• What I’m Trying To Do:
    Pull the last part of a URL to run against a switch statement to customize the query for my page-month.php page. Example URL: https://domain.com/month/june

    Then I will have page-month.php render the events for June, July, August, etc. Figured it was easier to setup a “month” page, instead of a page for every month.

    How It’s Setup:
    Using a custom post type for all events.

    I’ve got my homepage working correctly to check if it’s the current month

    <?php
    		$today_month = date('n', time());
    		$today_year = date('Y', time());
    		$args = array(
    			"post_type"	=> "events",
    			"orderby"	=> "meta_value_num",
    			"meta_key"	=> "_cal_start_date",
    			"order"		=> "ASC"
    		);
    		if($recent = new WP_Query($args)): $x=0;
    			while($recent->have_posts()) : $recent->the_post();
    				if($today_month == date('n',get_post_meta($post->ID, '_cal_start_date', true))):
    					include(TEMPLATEPATH . '/includes/entry.php');
    				endif;
    			endwhile; ?>

    …if there’s a better way, I’d love to know. Just need a way to search by the custom _cal_start_date meta field, per page, and the easiest way I thought of was being able to pull out the month name from the URL and customize my query from there. Thanks in advance.

  • The topic ‘Custom Calendar – Get Variable from URL String’ is closed to new replies.