• Resolved hennyyang

    (@hennyyang)


    Hi.

    I am wondering if there is any way I can retrieve a post title which I am in right now in the footer.

    For example, if I am in the post “Hello World” I want the footer say “Hello World”. When I am in the post “Hi WordPress” I want the footer say “Hi WordPress”. But I do not want pages to do that too.

    Is there any way to do so? Thank you!

    (I searched up any maybe it has something to do with “get_the_title”? I have no idea.)

Viewing 1 replies (of 1 total)
  • Hi @hennyyang

    In order to retrieve and print post title in the footer, you can either use any one of the snippet code

    <?php echo get_the_title($post->ID); ?>`
    OR
    <?php the_title(); ?>

    The code snippets are pretty self-explanatory, the only significant thing we have used is the global variable ‘$post’, it stores current active post object and thus allows us to retrieve various post related attributes such as Post ID, Post Name, etc.

    I hope you now have a solution to your query… Good Luck…

    Happy Programming ??

    Regards,
    Aashish

    • This reply was modified 5 years, 5 months ago by Aashish S. Reason: Remove, argument from the_post() method, as it was printing post id
Viewing 1 replies (of 1 total)
  • The topic ‘Retrieving Current Post Title to Footer’ is closed to new replies.