Modify available templates (in dropdown)

The list of available templates is generated by get_page_templates. By the end of this function you see a filter that allows you to modify the output. You can use that to change it under certain conditions like this: add_filter (‘theme_page_templates’,’wpse302574_conditional_templates’, 10, 4); function wpse302574_conditional_templates ($post_templates, $this, $post, $post_type) { $parent_id = wp_get_post_parent_id ($post->ID); if (get_page_template_slug … Read more

Query to get child pages of current page and display it in action hook

I was making a beginner’s mistake. I was not defining the global variable post. I publish my complete code for the community. May be useful for something like me. <?php add_action( ‘genesis_after_entry’, ‘capitulos_curso’ ); function capitulos_curso(){ global $post; $args = array( ‘post_type’ => ‘curso’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’, ‘orderby’ => … Read more

complex get_posts() query to select child pages

You need a loop for this to handle the condition: /** list for course and childless department pages */ $course_and_childless_department_pages = array(); /** get department pages */ $department_pages = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ) ); foreach ( $department_pages as $department_page ) { /** get course pages (for department … Read more

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