• [Moderator note: moved to Hacks Forum – the best place for custom coding questions]

    Hello to all
    For a reason of personalization of a wordpress page, I would like to delete
    The title tag of the “info” page

    I found on the internet this code that removes the <title> tag on all my site

    remove_action( 'wp_head', '_wp_render_title_tag', 1 );

    So the function is good

    But I would only delete the title tag from my info page

    Id = 45
    Slug = info
    Custom page => info.php

    Here my 2 tries but the condition does not work on this page

    if ( is_page_template( 'info.php' ) ) {
        remove_action( 'wp_head', '_wp_render_title_tag', 1 );
    }

    and

    if(is_page('info'))
    {
       remove_action( 'wp_head', '_wp_render_title_tag', 1 );
    }

    Can you tell me if there is an error?

    Thank you

    • This topic was modified 8 years, 2 months ago by bcworkz. Reason: moved to Hacks
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    Where did you place this code? I think the query has not yet determined the property used by is_page() or is_page_template() when your code executes. Try placing it within a callback to the “init” action.

    Thread Starter PECER

    (@pecer)

    Hello
    thank you for your reply,
    I tried this way but I do not know if it will work
    Because it still does not work in my site info page
    I was wrong?

    thanks

    function method_test() {
    if (is_page('info')){
       remove_action( 'wp_head', '_wp_render_title_tag', 1 );
       }
    }
    add_action('init', 'method_test');
    Moderator bcworkz

    (@bcworkz)

    No, that’s what I had in mind. I was wrong with “init”, but correct about needing a later hook. Please try “wp” instead of “init” for your action hook tag.

    Apparently “init” was still not late enough. “wp” fires even later, some important, crucial things happen in between.

    Thread Starter PECER

    (@pecer)

    hi,
    have you a example maybe?
    thanks

    Moderator bcworkz

    (@bcworkz)

    Try this:

    function method_test() {
    if (is_page('info')){
       remove_action( 'wp_head', '_wp_render_title_tag', 1 );
       }
    }
    add_action('wp', 'method_test');
    Thread Starter PECER

    (@pecer)

    Thank you it works now
    Just replaced init by wp, as you said
    But I was too tired yesterday to think

    Moderator bcworkz

    (@bcworkz)

    ?? I figured it had to be something like that. My obtuse sentence structure probably didn’t help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘remove tag only one page’ is closed to new replies.