php function to remove page titles no longer working

Homepage Community Forums Legacy Theme Support php function to remove page titles no longer working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10604
    Danna McCormick
    Customer

      URL: http://sampi.lunariffic.com/~morga47/
      Using: Legacy v2.0.2

      I have used this code snippet to remove Page Titles from Legacy and other child Themes for a long time without issue. However, it does not work with Legacy 2.0.2. It doesn’t break the site, but it just has no effect.

      
      /** Remove page titles */
      add_action( 'get_header', 'child_remove_page_titles' );
      function child_remove_page_titles() {
          if ( is_page() && ! is_page_template( 'page_blog.php' ) )
              remove_action( 'genesis_post_title', 'genesis_do_post_title' );
      }
      

      Would you provide a code snippet that will work with Legacy 2.0.2 ?
      Thank you!

      #10615
      Eric
      Customer

        I don’t think there is a version 2.02 just yet, 1.3 is the latest version.

        Since there were updates to Genesis 2.0 (the framework) the code changed. Here is the new way – https://appfinite.com/topic/remove-page-header/#post-7643

        remove_action( ‘genesis_entry_header’, ‘genesis_do_post_title’ );


        I create awesome sites for awesome people! Contact me if interested – ericsanchez1585@gmail.com

        #10623
        Danna McCormick
        Customer

          Hi Eric,
          Thanks for the response, and you’re correct – it is Legacy 1.3

          Unfortunately, this code does not work. It doesn’t break the site; but it also doesn’t remove the Page Titles.

          
          remove_action( ‘genesis_entry_header’, ‘genesis_do_post_title’ );
          

          The code on the page is this:

          
          <header class="entry-header">
          <h1 class="entry-title" itemprop="headline"> </h1>
          

          I’m going to head over to the Genesis forums and see what I can find… so odd. But please let me know if you find another solution.
          Thanks!

          #10626
          Danna McCormick
          Customer

            This is the php code that worked for my site. Found at this resource –
            http://wpsites.net/web-design/remove-titles-specific-conditions/

            
            add_action( 'get_header', 'remove_titles_all_single_pages' );
            function remove_titles_all_single_pages() {
                if ( is_singular('page') ) {
                    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
                }
            }
            
            #10627
            Eric
            Customer

              It worked for me, are you adding just that line alone? Also, make sure the '<!--formatted--> symbol shows up properly. The one from that link doesn’t show up right since they didn’t add it wrapped with the code block for the forums.

              Here are more ways that you can do it – http://bit.ly/1bMF9E3 that will show that code above, and it will also show some other ways to do it….example – if you wanted to remove a certain page title, or multiple page titles, or all page titles.

              Once you try out the second link, let me know if you get it working or not

              EDIT: I just realized, the code that I pasted above does in fact have the wrong ' symbol. Try this instead – remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); …and of course the second link above.


              I create awesome sites for awesome people! Contact me if interested – ericsanchez1585@gmail.com

              #10631
              Danna McCormick
              Customer

                Eric,
                Thanks for the link. I went back and tried the line with the correct characters and what I found was that it removed both Page and Post titles. I only want to remove Page titles (so I can add my own h1 headers).

                However, the link your provided is great. If I’m understanding it all correctly, there is not a way to remove all Page titles only because both Page and Post titles use the same genesis_entry_header. So, this code which specifically calls page titles – and I simply have to type in the Page IDs – will work best for my purposes.

                
                //* Remove page title for multiple pages (requires HTML5 theme support)
                //* Change page ids to match your needs
                add_action( 'get_header', 'child_remove_page_titles' );
                function child_remove_page_titles() {
                $pages = array( 63,65,67 );
                if ( is_page( $pages ) ) {
                remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
                }
                }
                

                Thanks so much for the resources!

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The topic ‘php function to remove page titles no longer working’ is closed to new replies.