WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Removing titles from a static page, but not all pages (8 posts)

  1. ChicagoBarrister
    Member
    Posted 4 years ago #

    I am trying to keep my website layout as clean as possible, and to this end, I would like to remove the h2 titles from two pages on my site.

    Specifically, I want to remove:

    1)the block letter "My Loans" (and the grey underline) from the top of http://www.chicagobarrister.com/my-loans/

    2)the block letter "Hire Me" (and the grey underline) from the top of http://www.chicagobarrister.com/hire-me/

    I've searched the forums, and tried inserting "display: none;", but that removed titles from all pages, including the titles of my posts on the homepage, http://www.chicagobarrister.com.

    Do I need to create a new page template for these two pages, or is there some way to remove titles based on the page id?

    Thanks in advance!
    Chad

  2. ClaytonJames
    Member
    Posted 4 years ago #

    If you intend to limit it's use to just one or two pages, I believe you could quickly create (copy the default, alter as desired and rename) just one new template and apply it to any pages fitting that design. Otherwise, an introduction to Conditional Tags might be in order.

  3. ChicagoBarrister
    Member
    Posted 4 years ago #

    Thanks!

    So I looked at some other threads for conditional tags and templates, and creating a new template seems to be the better option since it will allow more flexibility going forward.

    So do I need to copy, modify and rename "page.php"? If so, how do I get the two pages in question to use that template instead of the default? is it then selectable for those pages under "Edit Page" --> Attributes --> Template?

  4. ClaytonJames
    Member
    Posted 4 years ago #

    You can make your new page template unique by adding this to the very top of the page (no white space)

    <?php
    /*
    Template Name: Your_Template_Name
    */
    ?>

    Then name the file itself:

    your_template_name.php

    I believe it should then show up as a template of the same name in the drop-down area that can be applied when you create or modify a page.

  5. ChicagoBarrister
    Member
    Posted 4 years ago #

    Great... Thanks for all your help and I am very close to my goal!!

    I created a new template by adding the code you described and have the pages switched over to it. I modified the code to remove the titles from those pages and it works! So, I am 95% of the way there.

    All I need to do now is remove the grey underline from those pages. Here is the code from my new template. Do you know which part I need to modify to remove the grey underline? Thanks!!

    <?php
    /*
    Template Name: staticpage
    */
    ?>
    <?php get_header(); ?>
    <div id="content-body">
    <?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php if (function_exists("post_class")) post_class(); else print 'class="post"'; ?> id="post-<?php the_ID(); ?>">
    <h2><a style="display: none;" title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php edit_post_link(__('Edit this page','lightword'), '', ''); ?>
    
    <?php the_content(''); ?>
    <?php if(function_exists('wp_print')) { print_link(); } ?>
    <?php wp_link_pages('before=<div class="nav_link">'.__('PAGES','lightword').': &after=</div>&next_or_number=number&pagelink=<span class="page_number">%</span>'); ?>
    
    </div>
    <?php if ( comments_open() && $lw_disable_comments == "false" ) : comments_template(); endif; ?>
    <?php endwhile; else: ?>
    
    <h2><?php _e('Not Found','lightword'); ?></h2>
    <p><?php  _e("Sorry, but you are looking for something that isn't here.","lightword"); ?></p>
    
    <?php endif; ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  6. ChicagoBarrister
    Member
    Posted 4 years ago #

    I think I just figured it out!

    The grey underline was removed by deleting the entire h2 code instead of setting it to "display: none". Do you see any problem with doing that? There is nothing I can think of...

    Here's the final result: http://www.chicagobarrister.com/hire-me

    Big Thanks to ClaytonJames!

  7. ClaytonJames
    Member
    Posted 4 years ago #

    The underline is defined in your css at the post title h2.

    h2{background-color:#FFF;border-bottom:1px solid #DCDCDb;letter-spacing:-1px;font-size:24px;padding-bottom:3px;font-weight:400;margin:10px 0 3px 0;font-family:Helvetica, Georgia;}

    You can modify it there, which will affect ALL of the underlines under the h2 titles. Perhaps the easiest way would be to remove the entire h2 reference from your template and adjust from there. I know this seems sloppy, but perhaps one or two <br />'s in the template itself to replace the space removed with the h2. (Boy, that seems cheesy, but it's a quick, simple solution).

  8. ClaytonJames
    Member
    Posted 4 years ago #

    I think you have it! Like I said, if you want some of that top spacing back, a break or two might be the easiest solution. It's not elegant, but it will work.

    Best wishes!

Topic Closed

This topic has been closed to new replies.

About this Topic