Editing Complex Pages in Visual Mode

One thing you could do is create page templates for complex pages and simply add the content through the editor, leave as little mark-up as possible in the editor. Another thing that might help is using the editor style (activated with add_editor_style() in functions.php) and defined in editor-style.css so the client has a better sense … Read more

Set page template automatically based on parent

On the admin side, you could update the meta data for the page-post_type programmatically: global $post; if ( ‘swiss_cheese’ === $post->post_parent AND is_admin() ) update_post_meta( $post->ID, ‘_wp_page_template’, ‘some_template.php’ ); On the visitor facing side, you can simply jump into template redirect: function wpse63267_template_include( $template ) { global $post; if ( ‘swiss_cheese’ === $post->post_parent ) { … Read more

Allow only new sub-pages to be created

you actually don’t need any ajax or server side action, simple see if the user has selected a parent page: add_action( ‘admin_head-post-new.php’, ‘publish_admin_hook_wpse_78690’ ); add_action( ‘admin_head-post.php’, ‘publish_admin_hook_wpse_78690’ ); function publish_admin_hook_wpse_78690() { global $current_screen; if( ‘page’ != $current_screen->post_type ) return; ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#publish’).click(function() { var parent_id = jQuery(‘#parent_id’).val(); if (parseInt(parent_id) > 0){ … Read more

Create pages automatically if they don’t exist

I think you want: if( get_page_by_title( ‘home’ ) == NULL ) create_pages_fly( ‘home’ ); Your original if condition said if the page exists (does not equal NULL), then create the page. Also, the 2nd argument should be a string, though it doesn’t really matter in this case since it’ll just default to ‘page’ anyway.

Password protect page with multiple passwords

Here’s just a demo test for fun, just to see if this might be possible: Demo First we set the post’s password, the usual way: Then we create a custom field called wpse_extra_passwords that takes comma seperated passwords: These are the extra passwords for that post. Let’s define the following helper function, based on the … Read more

What is an alternative to get_page_by_title()?

If you don’t force a title, and obviously do not know the id, the only way you can do it is by letting the user select which page to use, usually done in the theme’s options page, but can be done in the costumizer, or even as part of page editing

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

How to add jQuery script to an individual page?

Although @s_ha_dum is correct you WILL need to use jQuery no conflict within WordPress the original question is left unanswered. I have this code which I want to add into a specific page of mine. There are a couple of ways to do this Based on Page name/slug WordPress in theme’s functions.php This method uses … Read more

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