wecobble / Subtitles

Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.
http://wordpress.org/plugins/subtitles/
GNU General Public License v2.0
117 stars 186 forks source link

Modifying Subtitles Markup #82

Closed geneus closed 8 years ago

geneus commented 8 years ago

Hi Philip.

As it stands following these instructions on modifying the plugin's markup, I cannot achieve my desired output.

Ideally, I'd like it to be output this way…

<header class="entry-header">
<h1 class="entry-title">This is my post's title</h1>
<p class="entry-subtitle">This is my post's subtitle</p>
</header>

I cannot achieve this. When I choose paragraph tags, it still outputs the markup inside the H1 tag.

<header class="entry-header">
<h1>
<span class="entry-title">This is my post's title</span>
<p class="entry-subtitle">This is my post's subtitle</p>
</h1>
</header>

When I use heading tags, I get the desired effect i.e. the post's title being the only text wrapped in the H1 tag.

<header class="entry-header">
<h1 class="entry-title">This is my post's title</h1>
<h6 class="entry-subtitle">This is my post's subtitle</h6>
</header>

The only problem is I do not want to wrap subtitle markup in headings. Something you advise too.

Is it possible to get my ideal output (first code block) when I use this…

function subtitle_markup_mods( $markup ) {
    $markup[ 'before' ] = '<p class="custom-subtitle-class">';
    $markup[ 'after' ] = '</p>';

    return $markup;
}

add_filter( 'subtitle_markup', 'subtitle_markup_mods' );

Using the span tag is okay too. I just need the subtitle markup to output outside the H1 tag. Any advice?

Thanks for your effort. Cheers!

geneus commented 8 years ago

I should have explored other issues prior to opening my own. After reading through #70, I followed your instructions which worked.

This…

function subtitle_markup_mods( $markup ) {
    $markup[ 'before' ] = '<p class="entry-subtitle">';
    $markup[ 'after' ] = '</p>';

    return $markup;
}

add_filter( 'subtitle_markup', 'subtitle_markup_mods' );

would be a superior way of doing it. Avoids mucking around in template files but can't complain. I achieved what I required despite an extra step or two.

Thanks @philiparthurmoore!

philiparthurmoore commented 8 years ago

@Geneus, awesome! I'm glad you were able to figure this out. Let me know if you run into any other issues.