Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi need to remove the title of a specific page, this one. I could do

add_filter( 'the_title', ai1ec_remove_title );

function ai1ec_remove_title( $title ) {
    if( 'Calendar' === $title ) {
        return '';
    } else {
        return $title;
    }
}

but this would also remove the title for any Post / Custom Post, titled calendar, i want to target specifically a page, is there a better way to do this?

share|improve this question
add comment

2 Answers 2

Well, why do you need a function to remove the title. Simply delete the title in the Editor, and moreover if you've already created the page the slug is created anyway. So now you can safely delete the title in your Page Editor and the title will not appear. Remember though, that this has global impact - meaning the title will not appear across entire site.

If however you wish to remove the title only on the single-page, then create a new page template and remove the code the_title() in that new template. And then, assign that template to your page. The title will not appear on that page.

share|improve this answer
    
I tried that, but that has an impact in the menus for example. I just want to remove that title and i do not want to touch the theme if possible. –  Nicola Peluchetti Jan 2 '13 at 14:44
add comment

You could target the ID of the page in the database. It is also passed as a 2nd parameter to the function. Assuming your ID to be "1234", the code becomes

add_filter( 'the_title', ai1ec_remove_title, 10, 2 );

function ai1ec_remove_title( $title, $id ) {
    if( 1234 == $id ) {
        return '';
    } else {
        return $title;
    }
}

Just make sure you replace the correct ID.

This doesn't work if you delete & create that page again from the admin panel. To be more scalable, better options are available. You could use custom fields which are then checked with the help of the ID or you might be storing the id's which to hide in theme options or somewhere else.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.