Page to output sub-pages (children)

You can use for example very basic WP Query (or get_pages or what ever. this is just one example) (http://codex.wordpress.org/Class_Reference/WP_Query) // The Query $currentPageId = $post->ID; // get current page id inside loop $args = array( ‘post_parent’ => $currentPageId, ‘post_type’ => ‘page’, ‘posts_per_page’ => -1 ); $query = new WP_Query( $args ); // The Loop … Read more

How to print the current post depth as update notification?

You should wrap your condition inside the function, rather than the function inside the condition (this will also prevent errors with code running too early as WordPress loads). function my_admin_notice() { global $wpdb, $post; $depth = $wpdb->get_var( $wpdb->prepare( “SELECT post_parent FROM $wpdb->posts WHERE ID = %d”, $post->ID ) ); if ( $depth == ‘0’ ) … Read more

List child categories from parent category on custom taxonomy page

Two things! 1) Don’t use query_posts()! Instead, for situations like this, use the pre_get_posts action to modify the query. 2) I don’t think you actually want to be using a loop here at all (so neither query_posts() nor pre_get_posts or even WP_Query). Rather, I think you’re looking for wp_list_categories. In your template, you’d probably do … Read more

If product is in sub-category show code

You can probably just make use of has_term( $term, $taxonomy, $post ) which will check if the specific post belongs to the term given You can do something like this (Edit: Add post ID if this is used in a function) global $post; if(has_term( ‘lucha’, ‘product_cat’, $post->ID )) { //do something if post has lucha term }else{ //do something … Read more

How do I display child post types in the parent post type template

After some digging I found the answer! Hopefully this helps some other people! EDIT Improved Answer! <?php $args = array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘airports’, ‘posts_per_page’ => -1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <h2><?php the_title(); ?></h2> <a href=”https://wordpress.stackexchange.com/questions/222748/<?php the_permalink(); ?>”> <button><?php _e(‘View’, ‘text_domain’); ?></button> </a> … Read more

get_pages displays only parents instead of children

The problem here is twofold. Firstly, you’re using ‘parent’ => $post->ID,. $post is a global variable, not a super global, so you have to state that you intend to use it before doing so with: global $post; But, as always, it’s easier to use the APIs than to go for the raw data, and you … Read more

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