WordPress.org

Ready to get started?Download WordPress

Forums

Remove title on selected pages. (10 posts)

  1. Emphasis
    Member
    Posted 3 years ago #

    First of all, I already checked the forum and most of them give a solution like

    "Post ID display none" or "Page title display none".

    1) Don't want all page titles to be deleted. I want the post titles to remain and the one on the Contact Page.
    2) Tried both (the /work page has ID 116 for example, I checked, but just no effect) http://www.niceflowertrading.com

    Thanks ahead!

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Can you be a bit more clear on what you're trying to accomplish?

    You want the Page Title not to appear on a known set of Pages?

  3. Emphasis
    Member
    Posted 3 years ago #

    I want to keep the titles on my posts.

    But I want to remove the titles of certain pages, most important of all, the one on http://www.niceflowertrading66.com/work

    It would be even more awesome if the title was removed and not just hidden, cause else there will be huge whitespace between title and content.

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    There are a couple of ways to accomplish this:

    1) Create a custom page template file (e.g. "page-no-title.php"), that omits the Page Title, then assign this template to whichever Pages for which you don't want to display the Title.

    or

    2) In your page.php template file, wrap a conditional around the call to the Page Title, so that it doesn't display for the specified Pages, e.g. if you wanted to omit the Page Title for Pages with IDs 3, 5, and 10:

    <?php
    $pages_to_omit_title = array( '3', '5', '10' ); // enter Page IDs, comma-separated
    global $page;
    $display_title = ( array_key_exists( $page->ID, $pages_to_omit_title ) ? false : true );
    
    if ( $display_title ) { ?>
         <h1><?php the_title(); ?></h1>
    <?php }
    ?>

    Note: untested

    (As you can see, the first option is probably the easier route.)

  5. Emphasis
    Member
    Posted 3 years ago #

    1) Had no succes with custom page, that is with the making of the template itself. Made a new .php file in my themes directory with all the normal code and left out the header stuff. But when I tried to make a page and assign the template, there were none to select.

    2) Wrapping around didnt work, but very likely that I didn't wrap it right.
    When I wrapped it like this:

    <?php
    $pages_to_omit_title = array( '200', '116', '2', '11' ); // enter Page IDs, comma-separated
    global $page;
    $display_title = ( array_key_exists( $page->ID, $pages_to_omit_title ) ? false : true );
    
    if ( $display_title ) { ?>
         <h2><?php the_title(); ?></h2>
    
    			<h2 class="entrytitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    <?php }
    ?>

    The post title appeared a second time

    When I wrapped it like this:

    <?php
    $pages_to_omit_title = array( '200', '116', '2', '11' ); // enter Page IDs, comma-separated
    global $page;
    $display_title = ( array_key_exists( $page->ID, $pages_to_omit_title ) ? false : true );
    
    			<h2 class="entrytitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    if ( $display_title ) { ?>
         <h2><?php the_title(); ?></h2>
    
    <?php }
    ?>

    I got an error: Parse error: syntax error, unexpected '<' in /usr/www/users/nicefl/wp-content/themes/karappo-style/index.php on line 18

    I want the dates gone on all the pages (except posts again) as well now. Sorry for the hastle :/

  6. 123milliseconds
    Member
    Posted 3 years ago #

    Please paste page.php at http://wordpress.pastebin.com/

    Select PHP syntax highlighting so we can easily read the code

  7. Emphasis
    Member
    Posted 3 years ago #

    Ok so first attempt looked like this:

    and gave me the title a second time

    Second attempt which gave me the syntax error had this wrapping:

  8. 123milliseconds
    Member
    Posted 3 years ago #

    1st attempt

    you have 2 titles; thats why

    remove line 7

    <h2><?php the_title(); ?></h2>

  9. Emphasis
    Member
    Posted 3 years ago #

    Yeah if I remove that one, the second title is gone indeed. But my title is still there, which I wanted to get rid of to start with :D

  10. Emphasis
    Member
    Posted 3 years ago #

    Ok nothing is working. Right now I'd be happy if it just displayed on the blogposts (http://www.niceflowertrading66.com/blog). No titles on the other pages.

    Can someone please help me out :(

Topic Closed

This topic has been closed to new replies.

About this Topic