How to display all subpages and short by year
How to display all subpages and short by year
How to display all subpages and short by year
So I can’t give you a complete solution but here are the pieces that I think might help: Getting parent post ID: wp_get_post_parent_id() – https://developer.wordpress.org/reference/functions/wp_get_post_parent_id/ Getting all posts with a particular parent ID. Here’s a WP_Query args to get all posts by parent ID $args = array( ‘post_parent’ => $parentID, ‘posts_per_page’ => -1, ‘orderby’ => … Read more
Verify if the current page has at least one published child
$args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, ); $children= new WP_Query( $args ); $seasonepisode = array( ‘post_title’ => $episodetitle, ‘post_content’ => ‘Some Content’, ‘post_status’ => ‘publish’, ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘page_template’ => ‘template-songlist.php’ ); if ( $children->have_posts() ){ while ( $children->have_posts() ) { $children->the_post(); if(get_the_title() != $episodetitle){ wp_insert_post($seasonepisode); … Read more
Due to wp_list_pages() leveraging get_pages() to actually retrieve the Page posts, and because get_pages() implements it’s own query logic independent of WP_Query‘s, it’s not possible to use arbitrary query variables which are not directly supported by get_pages(), including year, mothnum, day, date_query, etc. In order to continue using wp_list_pages() to this end, I think the … Read more
Child post with numeric only slug keeps redirecting to parent
I would use a custom walker and then extend the Walker_Page::start_el() method, like so: // Based on Walker_Page for WordPress v6.0 // @link https://github.com/WordPress/wordpress-develop/blob/6.0/src/wp-includes/class-walker-page.php#L105-L219 class My_Walker_Page extends Walker_Page { public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { /* This checks if the current page in the list … Read more
If it is about child post types* or taxonomies**: // page/post/cpt parent check: $post_object = get_queried_object(); // check if the page has a parent if ( $post_object->post_parent ) // do stuff // cat/tax parent check: $taxonomy_object = get_the_category( get_query_var(‘cat’) ); // check if the cat/tag/tax has a parent: if ( $taxonomy_object->parent ) // do stuff … Read more
There is a parameter in WP_Query called post_parent. Normally this refers to the ID of the post’s parent, but since its an integer field, pages without a parent have in essence a post_parent of 0. So, to get all pages that are not child pages of another page, you could use query_posts( ‘post_type=page&post_parent=0’ ); or, … Read more
Theme/Parent Theme/Child Theme usage is irrelevant here. Content is not added via Theme template file, no matter what Theme you use. Go to Dashboard -> Pages, and add new static Pages for each of your site’s pages. WordPress will generate them, and the Theme will display them. Edit ok so I figured out that I … Read more