Simple post for today. I have a optional plugin for a googlemap wich uses other custom post types wich supports the dimme_googlemaps in the post. You can read it all in the post type supports section. But what you need is a page wich to post the information, and the googlemap wich it supports.
Building it i have a simple settings form including a form on a settings page posting to options.php. You have to save the items through a hidden field. So in example:
<form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> <select name="dimme_option">etc</select> <input type="text" name="dimme_option_info"> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="dimme_option,dimme_option_info" /> </form>
Simple enough. Create a form with two fields, save it using the page_options hidden field. Comma seperated couse it has to be. But, i need a select getting the pages of my site so i can add a page option for the page i want my post type to get on. I can`t realy understand my last sentence.
So for an example. I want pages in a select:
wp_dropdown_pages($args);
Select created. Add a name and a “none” option and my page is.
$args = array( 'selected' => get_option('dimme_page_id'), 'name' => 'dimme_page_id', 'show_option_none' => '- choose -' );
Added my page, saves it to the options dimme_page_id, selected it default when selected. Add the args to the dropdown pages and done with the settings page. Now we can easily use the option in a template_include filter wich is not found in the wordpress codex, so an example:
function dimme_template_loader( $template ) { $page_id = get_option('dimme_page_id'); if ( is_page( $page_id )) { $template = plugin_dir_path(__FILE__) . 'mypage.php'; } return $template; } add_filter( 'template_include', 'dimme_template_loader' );