Only allow new subpages to be created

Code based in Bainternet’s answer to this question: Make Categories and Tags required in admin See code comments. add_action( ‘admin_head-post-new.php’, ‘wpse_59770_publish_admin_hook’ ); add_action( ‘admin_head-post.php’, ‘wpse_59770_publish_admin_hook’ ); add_action( ‘wp_ajax_wpse_59770_pre_submit_validation’, ‘wpse_59770_ajax_pre_submit_validation’ ); function wpse_59770_publish_admin_hook() { 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 form_data = jQuery(‘#parent_id’).val(); form_data = … Read more

Automatically set page order on create page

You could use ajax and the admin_footer-post-new.php hook. The sql would vary depending on whether you want the highest or most recently published order number. The following returns the highest published order number + 1: function wpse155926_set_menu_order() { $ret = array(); if ( check_ajax_referer( ‘wpse155926_set_menu_order_post’, ‘nonce’, false /*die*/ ) ) { global $wpdb; //last published … Read more

How restrict page for users logged? [closed]

Programmatically, you’d be looking for is_user_logged_in(). You’d want to put this in your header.php, or on the page itself: if ( is_user_logged_in() ) { // user logged in, redirect // One way to redirect is: // wp_redirect(‘http://YOURSITE.com/’); exit(); } else { // user not logged in, nothing } Otherwise, if you’re just looking for a … Read more

How do I load custom scripts and styles for a page?

Yes, you may add conditional tags to the wp_enqueue_scripts action. See the examples below: function load_assets() { wp_enqueue_style( ‘styles’, get_template_directory_uri() . ‘/css/styles.css’); // loads on any ‘page’ post type if( is_page() ){ wp_enqueue_script(‘main-js’, get_template_directory_uri() . ‘/js/main.js’); } // only loads on the page with a slug of ‘home’ if( is_page(‘home’) ){ wp_enqueue_script(‘home-js’, get_template_directory_uri() . ‘/js/home.js’); … Read more

Automatically change page password

The post/page passwords are stored in the wp_posts table in the post_password field. You can try the following demo plugin to update the post password automatically with help of wp-cron. You might alternatively consider transients or custom post meta. <?php /** * Plugin Name: Auto Post-Password Changer * Description: Schedule a wp-cron password update event … Read more

Increment Page Order As Pages Are Created

The following is a possible solution, but needs some testing to confirm it is viable. It runs only if menu_order == 0 and if it’s not an auto-draft or revision being saved add_action( ‘save_post’, ‘incremental_save_wpse_113767’, 10, 2 ); function incremental_save_wpse_113767( $post_id, $post_object ) { if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; if( defined( ‘DOING_AJAX’ … Read more

Dynamic content in a static page

You do want static pages. The easiest way to do this, and a very good way even if perhaps not the only way, is: Create one or more custom template files for your static pages. This is where your PHP comes in. /* Template Name: Calculator */ get_header(); // your calculator code // Whatever PHP … Read more

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