Allow Comments by Default for Multiple Post Types

function default_comments_on( $data ) { $myCustomPostType = array(“my_custom_post_type_1”, “my_custom_post_type_2”, “contacts”); /* Custom Post Type Array */ if (in_array($data[‘post_type’], $myCustomPostType)) { $data[‘comment_status’] = ‘open’; } return $data; } add_filter( ‘wp_insert_post_data’, ‘default_comments_on’ ); Add this code in functions.php

Child and Parent Pages list of sub pages

You need to work out what page level you are on first, so that you know the correct ID to pass to the child_of argument of wp_list_pages. Give this a try: global $post; $page_level = 0; $post_parent = null; // Work out what page level we’re on if($post->post_parent > 0) { $post_parent = get_post($post->post_parent); $page_level … Read more

wordpress dependent dropdownlist using post type is not working

PHP Select Doctors ‘doctors’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘dptmnt’, ‘value’ => $dpt, ‘compare’ => ‘LIKE’ ), ‘order’ => ‘ASC’ ), ); $events = new WP_Query($args); while ($events->have_posts()): $events->the_post(); ?> “> HTML Select Department ‘dpt’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); $events = new WP_Query($args); while ($events->have_posts()): … Read more

If is_page elseif is_page not working like I want it to

Well, if you take a look at the indentation of the code, which is correct, it should be pretty clear, why it is so. if (is_page(‘mounting-guides’)): $guides = get_field(‘guide_pdfs’); // you don’t do anything in this case elseif (is_page(‘user-manuals’)): $guides = get_field(‘user_manual_pdfs’); // you don’t do anything in this case elseif (is_page(‘cleaning-guides’)): $guides = get_field(‘cleaning_guide_pdfs’); … Read more

How to create dynamic templates?

You can include the template like this include(locate_template(‘template-part.php’));. to pass the variable or used the outer variable/ dynamic values in the template.