Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to Filter genesis_post_title_output
- This topic has 2 replies, 2 voices, and was last updated 10 years, 11 months ago by aaronc.
-
AuthorPosts
-
January 27, 2014 at 9:38 pm #87383aaroncMember
Hello all,
I need to modify the markup of the Entry Titles on my Archive pages. Currently, each Entry Title is wrapped in a <H1> tag; I need to change it to a <H2>.
I've found the filter genesis_post_title_output (post.php line 203), but can't seem to figure out how to properly implement it as it's a bit different than most other genesis filters.
/** * Echo the title of a post. * * The genesis_post_title_text filter is applied on the text of the title, while * the genesis_post_title_output filter is applied on the echoed markup. * * @since 1.1.0 * * @return null Returns early if the length of the title string is zero */ function genesis_do_post_title() { $title = apply_filters( 'genesis_post_title_text', get_the_title() ); if ( 0 == strlen( $title ) ) return; //* Link it, if necessary if ( ! is_singular() && apply_filters( 'genesis_link_post_title', true ) ) $title = sprintf( '<a href="%s" title="%s" rel="bookmark">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $title ); //* Wrap in H1 on singular pages $wrap = is_singular() ? 'h1' : 'h2'; //* Also, if HTML5 with semantic headings, wrap in H1 $wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap; //* Build the output $output = genesis_markup( array( 'html5' => "<{$wrap} %s>", 'xhtml' => sprintf( '<%s class="entry-title">%s</%s>', $wrap, $title, $wrap ), 'context' => 'entry-title', 'echo' => false, ) ); $output .= genesis_html5() ? "{$title}</{$wrap}>" : ''; echo apply_filters( 'genesis_post_title_output', "$output \n" ); }
How do I go about filtering my entry titles?
Thanks in advance,
AaronP.S. I'd also like to add a custom class and additional markup to my Page Titles. How would I use genesis_post_title_output to accomplish this?
January 28, 2014 at 6:09 am #87470mandomatMemberAaron,
I am responding because I have been trying to do something like this as well, and am anxious to see what kind of response you get. Thanks for asking this. MattFebruary 17, 2014 at 12:03 pm #90816aaroncMemberMatt,
I haven't been able to find a solid answer to my question, but I thought I'd share this article I found that offers one solution: http://sridharkatakam.com/remove-hyperlinks-post-titles-gensis/
The solution offered in the article simply includes the entire genesis_do_post_title() function, while removing and customizing the desired bits of code. This doesn't seem like the proper way to use the genesis_post_title_output filter, but it at least works.
I'm still interested to hear from the StudioPress community on how to properly use the genesis_post_title_output filter entry titles.
Thanks,
Aaron -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.