Get top level parent menu item title?

I would like to get the page title of the top most parent page. For example..

Pets
\- Dogs
\– Basset Hound
\– Cocker Spaniel
\- Cats

If I am on the **Cocker Spaniel** page I want to be able to get the page title of **Pets.** My goal is to put this page title into a shortcode that I can use in Elementor.

1 Comment
  1. Something like this

    $parentid = wp_get_post_parent_id(get_the_ID())
    echo get_the_title($patentid);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer