[resolved] Removing title from a single page or post using Custom Fields (5 posts)

  1. zerpex
    Posted 4 years ago #

    Hello, Lots of questions from me..

    Anyway - Is there any way to remove a page or post title using custom fields? - Instead of manually add it to the CSS, or don't give the page or post any name?

    Best regards,

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    <?php if ( !get_post_meta($post->ID, 'no_title', true) ) : ?>
    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s'), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php endif; ?>
  3. zerpex
    Posted 4 years ago #

    Thank you Esmi

  4. adi339
    Posted 4 years ago #

    I have the same question but do not understand the answer. Do I have to edit the code to put that code in, or is that used in the custom fields area (which I read about and still don't understand)?


  5. Driftless
    Posted 4 years ago #

    adl339 -

    The code above shows how to check whether a 'no_title' custom field has been set, and if it has, then don't show the title. If it has not, then show the title.

    IF you are looking to not show ANY titles EVER - then it is easier to just edit your theme's template.

    Otherwise - start diving into custom meta.

Topic Closed

This topic has been closed to new replies.

About this Topic