slug = $slug; $this->postType = jvbCheckBase($slug); $this->registrar = $registrar; add_action('template_redirect', [$this, 'redirectChildToParent']); } /** * Set $this->is_timeline * @return void */ public function redirectChildToParent(): void { if (!is_singular($this->postType)) { return; } global $post; // If this post has a parent, redirect to parent if ($post->post_parent) { $parent_url = get_permalink($post->post_parent); // Add anchor or query param to indicate which child was accessed $redirect_url = add_query_arg('update', $post->ID, $parent_url); wp_redirect($redirect_url, 301); exit; } } }