Get Grandparent’s Title
-
Hi,
Please kindly help.
It seems that I can’t get the grandparent’s title of CPT posts.
I already use the below code, but so far I only get the parent post title.
<?php $current = $post->ID; $parent = $post->post_parent; $grandparent_get = get_post($parent); $grandparent = $grandparent_get->post_parent; echo get_the_title($grandparent); ?>
This is my CPT’s settings.
name: series label: Series singular_label: Serie description: "" public: true publicly_queryable: true show_ui: true show_in_nav_menus: true delete_with_user: false show_in_rest: true rest_base: series rest_controller_class: "" rest_namespace: "" has_archive: true has_archive_string: "" exclude_from_search: false capability_type: post hierarchical: true can_export: false rewrite: true rewrite_slug: "" rewrite_withfront: true query_var: true query_var_slug: "" menu_position: "" show_in_menu: true show_in_menu_string: "" menu_icon: dashicons-welcome-view-site custom_supports: "" enter_title_here: Add Serie
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get Grandparent’s Title’ is closed to new replies.