Add custom admin menu item for pages using a certain template

If this is what you want: … you can do it like so: Step #1: Add the custom menu item (Retailer Sendout). function add_retailer_sendout_admin_menu() { $slug = ‘edit.php?post_type=page&template=page-retailer-sendout.php’; add_menu_page( ‘Retailer Sendout’, ‘Retailer Sendout’, ‘edit_pages’, $slug, ”, ‘dashicons-admin-page’, 19 ); } add_action( ‘admin_menu’, ‘add_retailer_sendout_admin_menu’ ); Notes: I’m using add_menu_page() to add the menu (which is a … Read more

page_template toggle between 2 templates + 2 permalinks for same post

WordPress has a simpler function for what you’re trying to do, add_rewrite_endpoint. Additionally, the filter for a single post template is single_template, page_template fires on the page post type. function wpd_detail_endpoint(){ add_rewrite_endpoint( ‘detail’, EP_PERMALINK ); } add_action( ‘init’, ‘wpd_detail_endpoint’ ); function wpd_detail_template( $template=”” ) { global $wp_query; if( ! array_key_exists( ‘detail’, $wp_query->query_vars ) ) return … Read more

Dynamically override page.php or single.php with custom templates using function

One way you can do that is by adding a filter to the hook {$type}_template. Sample code: function my_plugin_custom_template( $template, $type ) { switch ( $type ) { case ‘page’: $template=”/path/to/custom-page-template”; break; case ‘single’: $template=”/path/to/custom-single-template”; break; } return $template; } add_filter( ‘page_template’, ‘my_plugin_custom_template’, 10, 2 ); // Filter for page.php add_filter( ‘single_template’, ‘my_plugin_custom_template’, 10, 2 … Read more

Schedule Sticky Posts

The issue is that you limit query to the two possible posts, but by default it will ignore the future one (since that’s the point of it not being published yet). Also the ID order is not guaranteed to be same as date order. ID is reserved when post is first created but date it … Read more

Page Templates – this code only works for one Custom Post Type

Dump the constant MY_CUSTOM_POST_TYPE use the $post->post_type instead. /** * Register the meta box */ add_action(‘add_meta_boxes’, ‘page_templates_dropdown_metabox’); function page_templates_dropdown_metabox(){ global $post; add_meta_box( $post->post_type.’-page-template’, __(‘Template’, ‘my_template’), ‘render_page_template_dropdown_metabox’, $post->post_type, ‘side’, #I prefer placement under the post actions meta box ‘low’ ); } /** * Render your metabox – This code is similar to what is rendered on … Read more

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