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

Display a list of child posts on parent posts of a custom post type

The best way is using WP_Query. I think your error or plugin error could be that the ‘post_type’ of childs is not define. WP Query : https://codex.wordpress.org/Class_Reference/WP_Query global $post; $args = array( ‘post_parent’ => $post->ID, ‘posts_per_page’ => -1, ‘post_type’ => ‘products’, //you can use also ‘any’ ); $the_query = new WP_Query( $args ); // The … Read more

Check if is on child-page of a particular page

You can do that with $post->post_parent. You will have to check if child page’s parent is Services page. So this is how you will check it. I assumed 123 in following code is page ID of your services page. Replace it with actual ID. if ( 123 == $post->post_parent ) { ?> <div class=”col-md-2 col-sm-4″> … Read more

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