Using single.php from plugin folder instead of default template folder

I think a hook into template_include like described here could be a proper way to do this. Code could be like this: add_filter(‘template_include’, ‘my_plugin_templates’); function my_plugin_templates( $template ) { $post_types = array(‘post’); if (is_singular($post_types)) { $template=”path/to/singular/template/in/plugin/folder.php”; } return $template; }

How to list ALL Pages in the dashboard?

If that listing has too many pages, maybe you’ll run into troubles. You probably already know that this can be set in the Screen Options of the page http://example.com/wp-admin/edit.php?post_type=page. If you try to put a really high value there, this warning pops up and the system doesn’t accept it: But the following permanently sets this … Read more

Add a Page without header and menus?

Create a custom Page Template, leave out the get_header(), get_footer(), and get_sidebar() calls in it, and put in your own html header/footer code in the Page template instead. http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

WP Multisite: Adding pages on blog creation by default

The hook is not the problem – your code runs in the context of the current site, not the one just created! The following code isn’t tested, but it should at least highlight the problem: function wpse_71863_default_pages( $new_site ) { $default_pages = array( ‘Impress’, ‘Contact’, ); switch_to_blog( $new_site->id ); if ( $current_pages = get_pages() ) … Read more

how to limit edit_form_after_title hook to page and post edit only?

Personally I’d use a different approach, because @Shazzad‘s solution seems too much global dependent, and @s_ha_dum‘s needs 2 hooks instead of one. I’d use get_current_screen function to get a WP_Screen object, then I’d look at its property to run (or not) something after the title: function do_something_after_title() { $scr = get_current_screen(); if ( ( $scr->base … Read more

Creating a WordPress admin page without a menu for a plugin

I am less convinced that I know what you are doing than I once was. // Add menu and pages to WordPress admin area add_action(‘admin_menu’, ‘myplugin_create_top_level_menu’); function myplugin_create_top_level_menu() { // This is the menu on the side add_menu_page( ‘MyPlugin’, ‘MyPlugin’, ‘manage_options’, ‘myplugin-top-level-page’ ); // This is the first page that is displayed when the menu … Read more

How to add add_meta_box to specific Page Template?

If your custom page template filename is foobar.php, you can use get_post_meta(): global $post; if ( ‘foobar.php’ == get_post_meta( $post->ID, ‘_wp_page_template’, true ) ) { // The current page has the foobar template assigned // do something } Personally, I like calling this inside my add_meta_boxes_page callback, and wrapping it around the add_meta_box() call itself. … Read more

Page begins with number, WordPress adds 2

Within the wp_unique_post_slug function, checks are made to “Prevent new post slugs that could result in URLs that conflict with date archives.” Here’s the relevant code from line 3812 from wp-includes/post.php // Prevent new post slugs that could result in URLs that conflict with date archives. $post = get_post( $post_ID ); $conflicts_with_date_archive = false; if … Read more

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