WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Filter - the_title - finding out context (5 posts)

  1. willkemp
    Member
    Posted 5 years ago #

    I want to run run a filter when the_title is called, to change the page title, but i need to be able to work out whether it's been called from the loop or from the "pages" widget in the sidebar.

    I can filter the_title and check if it's the page title i want to change, but the page title also appears in the sidebar menu and i don't want to change that too.

    Is there any way to work out what context the_title has been called from?

  2. willkemp
    Member
    Posted 5 years ago #

    After quite a bit of groping around google, i've managed to stumble on the answer: the in_the_loop() function.

    See the codex "Conditional Tags" page for more info and similar functions.

  3. datafeedr
    Member
    Posted 5 years ago #

    Nice find, willkemp!

  4. brooknovak
    Member
    Posted 4 years ago #

    YES! Legend!

  5. Gouri
    Member
    Posted 4 years ago #

    @ willkemp
    Thanks for sharing that; I may require it while tweaking my blog theme.

Topic Closed

This topic has been closed to new replies.

About this Topic