Custom post type hierarchical loop in Homepage

From the look of your code, all you are doing is creating a nested list. If so, the easiest thing would be wp_list_pages. $args = array( ‘post_type’ => ‘cliente’, ‘post_status’ => ‘publish’, ‘author’ => $idutente, // must be comma separated list of IDs ); wp_list_pages($args); wp_list_pages only seems to work with ‘hierarchical’ => true,, but … Read more

Delete child post and attachment links to parent post

There’s no way of doing this without “listening” for the responsible database query and altering it with the query filter, thanks to this line in wp_delete_post(): // Point all attachments to this post up one level $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( ‘post_type’ => ‘attachment’ ) ); The following will override the query and set … 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

Query all post types but limit to parents

In your functions.php you can create a function that will hook into the pre_get_posts hook. Something like (just an example): function alter_query($query){ $query->set(‘post_parent’, 0); } add_action( ‘pre_get_posts’, ‘alter_query’ ); There you can alter the main query. That way while(have_posts()) : the_post(); will still just normally work. (You should check if you are altering the right … Read more

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