Skip to content
Advertisement

How to get the wordpress archive title? Is their any function for checking the title of current page displayed?

I am a beginner in PHP!

I am using Free Kadance theme on WordPress.

In the Theme customization option >> Homepage Settings >> we can toggle the title ON or OFF.

If we toggle the title ON it will display the title of the website on homepage with the latest posts. I like to display the page title along with some description text on that home page. After sometime of analysis inside WordPress Theme editor.

On WordPress Theme editor >> template-parts >> archive-title >>title.php

There is a section of php code

JavaScript

This section of code is responsible for printing the header text that we toggle ON.

Is there some way to get the text which is printed by function: the_archive_title( )

If I can get that text to a variable, then I can check that statement to the title string and if both are equal I could execute desired php file.

Somebody please help!

I tried

JavaScript

Result : It worked partially! But every Archive page displayed a text “title_var_to_check” under it.

Advertisement

Answer

You need add $ to title_var_to_check

JavaScript

and

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement