How to remove page name from beginning of pages but NOT from posts

Community Forums Forums Design Tips and Tricks How to remove page name from beginning of pages but NOT from posts

This topic is: not resolved

This topic contains 10 replies, has 4 voices, and was last updated by  eluviis 1 year, 5 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #8598

    docmas
    Participant
    Post count: 40

    Was given the following code to add in response to previous inquiry on removing page name/title from top of pages which worked, but also removed them from top of posts, which I don’t want to happen.

     

    You can add this to style.css.  I suggest adding it to the Headlines section.

    h1.entry-title {
    display: none;
    }

     

    I did place it in headlines section, is there somewhere else to place or some other code to add?

     

    http://thepassiondoctor.com

     

    Thanks,

    Adam Sheck

    #8628

    Brian Bourn
    Participant
    Post count: 96

    You can add this function to your functions.php file and it will remove the automatic page title from all pages, except the blog template & will keep it on posts.

    //***Remove Page Titles From All Pages Except Blog Page Template**/
    add_action( 'get_header', 'bourncreative_remove_page_titles' );
    function bourncreative_remove_page_titles() {
    if ( is_page() && ! is_page_template( 'page_blog.php' ) )
    remove_action( 'genesis_post_title', 'genesis_do_post_title' );
    }

    You can also try the plugin Genesis Title Toggle. http://wordpress.org/extend/plugins/genesis-title-toggle/


    Bourn Creative | bourncreative.com | Twitter

    #8650

    docmas
    Participant
    Post count: 40

    I added this code and it gave me a critical syntax error, took out entire blog.  Even after I deleted it, still there, which makes no sense, had to reinstall Agency.  Did this twice with same result.  Any suggestions?

    Hate to use the Toggle plugin, which hasn’t been updated in some time PLUS worried adding more plugins will slow things down.

    Thoughts?

    Adam

    #8651

    Brian Bourn
    Participant
    Post count: 96

    Probably something to do with copy/pasting. We use this snippet on every Genesis site we build. Try grabbing it from here:


    Bourn Creative | bourncreative.com | Twitter

    #8670

    docmas
    Participant
    Post count: 40

    thanks, i’ll try again, AFTER i backup the agency theme, had to reinstall it twice and then add my other customizations.  hopefully no invisible characters in this one.

    have the plugin installed, but as i said, less is definitely more on wordpress.

    adam

    #24736

    eluviis
    Participant
    Post count: 115

    docmas, it’s better to edit functions.php on your desktop and upload via FTP after every update. That way if you break the site with a tiny PHP error, all it takes is fixing the error in the file on your desktop and re-uploading – and all it fine with the world after that.

    @Brian Bourn – I want to use that snippet, but I was originally going to apply a page ID to it to only use it on one specific page (a landing page), in my case page-ID 176.

    Any tips on editing that code to make it target id-176 only?

    I undertand why you apply it to all pages. It’s probably an SEO thing so that you can have a short page permalink, with a long H1 tag for your title. I do that sometimes by publishing the page first and then changing the title afterwards so the permalink doesn’t change. However, in this case I simply want to add a <div> wrapped H1 tag in the body of the landing page itself. In order to avoid having 2 sets of H1 tags in my page, I want to remove the title (which automatically gets an H1). You think this code snippet with a little edit would do the trick?

    #24763

    frobn
    Participant
    Post count: 18

    The page name and page id are in the body classes

    Try

    [css]</pre>
    /* landing page */

    .landing . entry-title {display:none;}
    <pre>
    /*specific page*/
    .page-id-176 .entry-title {display:none;
    }
    [/css]

    #24810

    eluviis
    Participant
    Post count: 115

    Hi, oh, I know how to find the post and page id’s. The CSS is relatively simple. What  I’m unsure of is editing Brian Bourn’s PHP code from “page template” to “page-id.” What I need done has to be done via PHP and not CSS.  It’s not simply a display issue, it’s also an SEO issue. If I hide the title using CSS, I will still have the title in the code wrapped in H1 tags. I can’t have that because I want to apply H1 tags to a specific line of text in the body of my page – I’d end up with two different lines of text wrapped in H1, and you should only have 1. Using PHP to remove the title from the page will do it cleanly – also removing it from the source code of the page, not simply hiding it like CSS does. See what I mean?

    #24836

    frobn
    Participant
    Post count: 18

    Include the page-id # in Bourn’s PHP

    if ( is_page( page# )

    #24840

    eluviis
    Participant
    Post count: 115

    ^ Ok great, I’ll try that. Not sure what all the divs in each line are for though. I suppose I don’t need to include those, right?

    #25222

    eluviis
    Participant
    Post count: 115

    Finally got around to trying this. @frobn – That worked perfectly, thanks. (Had to get a bit of help from a friend as well) Here’s the edited snippet:

    //** Remove page title from About Page landing page */
    add_action( ‘get_header’, ‘bourncreative_remove_page_titles’ );
    function bourncreative_remove_page_titles() {
    if ( is_page(176))
    remove_action( ‘genesis_post_title’, ‘genesis_do_post_title’ );
    }

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.