[theme-reviewers] No-Title Filter for the_title()

michael at mfields.org michael at mfields.org
Tue Mar 8 20:39:30 UTC 2011


Right on, I can totally see that need. The main thing the erks me about
solutions such as this is that they take the authors intentions and throw
them out the window. If I am writing a post and I choose to leave the
title blank, I would expect the title to be blank. I do not want the title
replaced with "no title". To me it has the effect of a designer leaving in
FPO images in a finished design ... IMO it looks sloppy.

If a permalink is needed, I would suggest that it be added somewhere else
in the template in a conditional check. the_title can still be used for
this:

$title = the_title( '', '', false );
if ( empty( $title ) ) {
    print '<a href="' . esc_url( get_permalink() ) . '">Permalink</a>';
}

-Mike


> The issue arises when Post Title is the only available permalink to the
> Single-Post view. In this case, the developer may want to provide text
> such
> as "No Title", etc., so that the permalink still gets displayed.
>
> Chip
>
> On Tue, Mar 8, 2011 at 2:15 PM, <michael at mfields.org> wrote:
>
>> Is there a need for a conditional test?
>>
>> I wrap all my code within the function and the conditional as pect is
>> handled for you:
>>
>> the_title( '<h2>', '</h2>' );
>>
>> This way the tags will not be printed if the title is empty.
>>
>> -Mike
>>
>> > Ran across this suggestion on the WPORG support forums:
>> >
>> >
>> http://wordpress.org/support/topic/handling-display-of-title-when-none-exists?replies=1
>> >
>> > I like this approach; it is cleaner than performing a conditional test
>> in
>> > the template file.
>> >
>> > Just thought I'd pass it along...
>> >
>> > Chip
>> > _______________________________________________
>> > theme-reviewers mailing list
>> > theme-reviewers at lists.wordpress.org
>> > http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>> >
>>
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>




More information about the theme-reviewers mailing list