• Resolved sam

    (@samjoelnang)


    I love the plugin and we’ve been using it on our blog particularly for track and album reviews. While the practice has been to put as title simply Artist Name – “Song Title” or Artist Name – Album Title, we recently decided to utilize the Secondary Title plugin by entering in the field a compelling headline that is shown as the title when the actual post is visited. However, Secondary Title seems to not recognize the <i> and </i> tags, which supposedly should italicize any enclosed word. We need this when writing, for example, a headline that goes, “Artist releases 30-track effort Album Title“, which we intend to replace the original title “Artist Name – Album Title“. Is this not a feature of the plugin yet?

    • This topic was modified 3 months, 1 week ago by sam.
    • This topic was modified 3 months, 1 week ago by sam.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Hi @samjoelnang,

    Thanks for your message.

    Where exactly are you entering the <i> tags?

    Thread Starter sam

    (@samjoelnang)

    Hi @thaikolja, I enter it in the Secondary Title field, enclosing the word I want italicized, but it does not seem to have an effect to the word at all, so I thought maybe it’s not yet possible. I only intend to italicize a certain word within the Secondary Title and not the whole Secondary Title.

    Plugin Author thaikolja

    (@thaikolja)

    Thanks, @samjoelnang. It sounds like you entered the <i> tag into the field when editing or adding a post, is that right?

    This is absolutely possible as you can see in the official documentation I’m working on. I just tried to reproduce your issue with clean WP site and the plugin’s default settings, and it worked as it should.

    This is how it looks in the post editor (I assume you do it the same way from what you’ve told me):

    And, under “Settings” -> “Secondary Title”, I chose the following title format:

    %secondary_title%: %title%

    “Auto show” must be enabled for this to work. Also, make sure that you don’t restrict the display only show for posts in certain categories, specific post IDs, or post types. Leaving them all blank means they apply to all posts.

    The result looks like this:

    Now, if you still have this issue, it’s most definitely your theme that strips out HTML tags in titles for security reasons. While this is crucial and also implemented in Secondary Title (e.g., you can’t use <script> tags and others that may be abused for cross-site scripting (XSS), but I limited it to allow general formatting, including <i>.

    What you can do if you’re still facing this problem:

    1. Go to “Settings” -> “Secondary Title”
    2. Wrap the secondary title (or which part you’d like to italicize it) inside a <span> tag and give it a distinctive CSS class, for example secondary-title. The full title format would look like this: %secondary_title%: %title%
    3. Having done that, head over to “Appearance” -> “Customize” and use the CSS area to style this particular class.

    In your HTML source code which you can view in your browser, the code surrounding your title should look like this then:

    Here’s one example of what you could put in the CSS editor if you use the secondary-title as class:

    .secondary-title {
    font-style: italic;
    }

    If that works, it’s a good idea to narrow down the scope since it now applies to every class that’s called secondary-title everywhere on your website.

    I’ve had quick look on your website structure and this CSS code seems to be a good way to only show the secondary title in italic on post lists and single posts:

    .wp-block-post, .wp-block-post-content {
    .secondary-title {
    font-style: italic;
    }
    }

    I hope this all makes sense. If you need more assistance, don’t hesitate to ask. And if it worked, please let me know so I can close this ticket. If you’re pleased with the plugin and my support, I’d also be very grateful if you’d give my plugin a little review ??

    By the way, I’m working on a comprehensive, easy-to-understand documentation for Secondary Title that you can find here:

    https://docs.kolja-nolte.com/secondary-title/

    If you like, I’d be thankful if you had any feedback.

    • This reply was modified 3 months, 1 week ago by thaikolja.
    • This reply was modified 3 months, 1 week ago by thaikolja. Reason: Formatting
    Thread Starter sam

    (@samjoelnang)

    Hi @thaikolja, thanks for the detailed and easy-to-follow guide, however, we might not be on the same page I’m afraid. I’ve had a look at the plugin’s documentation before creating this topic as I did not find the solution.

    What I’m trying to italicize is only a certain word in the Secondary Title and not all of it. Our default title for an article, for example, goes like “Metallica – Master of Puppets“, which, when opened, we want to display as a headline in sentence case, like “Metallica reissues Master of Puppets” and not “Metallica reissues Master of Puppets” like your advice would result in. Additionally, we don’t want to display this as %secondary_title%: %title% as we want the Secondary Title to replace the default title when the actual post is viewed.

    Plugin Author thaikolja

    (@thaikolja)

    Puh, now you made me write all that stuff, and it was completely useless? Just kidding, it’s me who keeps misunderstanding it ?? To be frank, I’m still not entirely sure if I get it right, so please bear with me.

    As general info: You can use HTML tags to style the output; you know that part already. You can use it both on the settings page for the “Title Format” which will be applied to every post title (and therefore replaces it) as well as in individual posts via the input field. Note that some tags are stripped for security reasons, but <i> is definitely allowed.

    If I understand you correctly, you want to have two different versions of a title that both have different title formats. To stay with our aging metal friends, the post titles on the front page look like this (I’ll leave out the styling for now):

    Metallica - Master of Puppets

    And when you visit that post, you want it to turn into this:

    Metallica reissues Master of Puppets

    where only the secondary title is styled.

    I’m sorry, but this use case isn’t possible with the “Auto Show” function. You’d have to manually do this in your theme (or better: child theme). That’s what the manual mode is for.

    Before I go on, please tell me if I got it correctly this time and if you’d like me to give you a code snippet that you can put into the functions.php file of your (child theme) to achieve that or if that’s too much hassle for you.

    I’m also in the process of updating the documentation with a lot more information and examples, but as of right now, the only relevant section would be this. But your use case – assuming I got it right – is a good idea to address on the Exampels page.

    • This reply was modified 3 months, 1 week ago by thaikolja.
    Thread Starter sam

    (@samjoelnang)

    Hi @thaikolja, sorry you had to write all that ?? your inputs are definitely not useless! I’d say you got it right this time, except that I must emphasize that we do not intend to italicize all of the Secondary Title but only certain words as needed (like when an album title is mentioned). In your example, we would like the Secondary Title to show as

    Metallica reissues Master of Puppets

    or only whenever italicization is necessary.

    The italicized word or words could be anywhere in the Secondary Title:

    Listen to Metallica's Master of Puppets reimagined to the style of Radiohead's The Bends

    which would only be possible if <i> gets recognized therein.

    I am comfortable with some code should you provide me with any and I look forward to trying it out. I truly appreciate your help.

    Plugin Author thaikolja

    (@thaikolja)

    Hi @samjoelnang,

    Last and probably most crucial question: Are you still using the “Title Format” option in any way or does it contain only %title%?

    And I saw that you’re using two secondary titles in your example. Where would you enter the two titles that are to be italicized? In the input field in the post editor, separated by a comma? And is the <i> format likely to change at some point, maybe into a <bold> (since the <i> styling tag is currently hard-coded in the snippet)?

    Edit: This is the solution I came up with while waiting for your reply:

    The input field for the secondary title on the add/edit post screen looks like this:

    Master of Puppets, The Bends

    Of course, this also works with just one or more words.

    The original title, though, is the full title, without styling the specific words:

    Listen to Metallica's?Master of Puppets?reimagined to the style of Radiohead's?The Bends

    All this requires Secondary Title’s “Auto Show” function to be set to “On” and the “Title Format” to be simply:

    %title%

    However, as asked above, I’m not sure whether you expect a version of title on the front-page and a different version of the title when viewing a single post, i.e (italicization included):

    Front page:

    New version of Metallica's?Master of Puppets?released

    Single post:

    Listen to Metallica's?Master of Puppets?reimagined to the style of Radiohead's?The Bends

    Please have a look and let me know.

    • This reply was modified 3 months, 1 week ago by thaikolja.
    • This reply was modified 3 months, 1 week ago by thaikolja.
    • This reply was modified 3 months, 1 week ago by thaikolja.
    • This reply was modified 3 months, 1 week ago by thaikolja.
    Plugin Author thaikolja

    (@thaikolja)

    Hi @samjoelnang,

    I went ahead and finalized the script. Please don’t tell me I got it wrong again; I might cry myself to sleep otherwise ?? No, really, I’m committed to helping you, and if it’s not what you had in mind, please do say so.

    I’ve uploaded the script to my public GitLab profile with brief instructions, which is more for documentation purposes since I have a lot of scripts like these and sometimes forget how they work or what they actually do. Here’s the link:

    https://gitlab.com/-/snippets/3739088

    The “installation” is clear, as written in the description: Copy and paste the content of the script into the functions.php file of your active theme, and you should be good to go.

    On a side note, I tested it thoroughly, but even after hours, I can’t anticipate every kind of use case. So, if you run into problems, please get back to me, assuming this is actually the solution to what you want to achieve.

    Cheers!

    Thread Starter sam

    (@samjoelnang)

    Hi @thaikolja, thank you for going as far as writing such a complicated code to help! I tried implementing the same. Set the Title format to %title% and entered the Album Title in the Secondary Title field in the Editor, which did result in the actual post displaying the post title with the Album Title automatically italicized. This is fantastic if we only wanted to do an automatic italicization of certain words in a headline already in sentence case. However, this is not what we’re aiming for when writing track or album reviews. Also, italicizing any word in a headline is already possible through the default title field by adding the <i> tag.

    To clarify, track/album reviews are titled this way (using the default title field):

    Artist Name - "Song Title" (for track reviews) or Artist Name - Album Title (for album reviews)

    This is how they appear on the front page or other parts of the blog. This is because reviews are shown like vinyl or CDs.

    This has been the practice for a long time, but going forward we want the title to change into a headline in sentence case when the single post (the actual post) is viewed:

    Artist Name - "Song Title" (original title) → Artist Name releases new song "Song Title" (on actual post)

    Artist Name - Album Title (original title) → Oddity pervades Album Title, the latest album by Artist Name (on actual post)

    Using the plugin Secondary Title is a great help to achieve that, except that we cannot seem to italicize any word (particularly when it comes to Album Titles) inside the field as needed.

    The above secondary title is written as Midnight Zephyr float through genres with debut EP <i>Tonight</i> inside the Secondary Title field, but as you can see, the word Tonight does not become italicized.

    Your solution is actually a great feature, although I think it could develop into a whole new plugin where a user is to put in the field a word or words they want automatically italicized/stylized instead of providing a completely alternative title.

    We already are able to italicize Album Titles using the <i> tag in the default title field when writing news stories, which require headlines by default and where Secondary Title is no longer needed. We only have a problem especially with album/EP reviews, because we need it (Album Title) to be italicized, without affecting the other words in the secondary title as illustrated above.

    That said, I think this can be achieved with a script that allows <i> or <strong> or any styling tags to be put “anywhere” inside the Secondary Title field in that when one enters therein, for example, Oddity pervades <i>Album Title</i>, the latest album by Artist Name, it gets read as a command to italicize whatever is enclosed by the tags, to the exclusion of all other words.

    I appreciate your effort in making this plugin more flexible and your patience in addressing my query. Really looking forward to getting this to work!

    Plugin Author thaikolja

    (@thaikolja)

    Hi @samjoelnang,

    I also appreciate your patience, your patience with me, but some of your explanations still seem contradictory to me. Or maybe I just stare at too much code at work and fail to see it.

    I suggest we move this discussion to a messenger app. I’d be most comfortable with Telegram, but I can also do WhatsApp if that suits you better. Addressing things line by line, so to speak, seems to me to be a faster and better way to clarify things before I end up writing another useless piece of code ??

    If you’re cool with that, please reach out to me via kolja (dot) nolte (at) gmail (dot) com. Then, we can share IDs/numbers and get you where you want to be a lot faster and, most importantly, without misunderstandings.

    I’m not sure where you’re located, but just so you know, I live in Bangkok (GMT+7). But don’t worry, I can make time to resolve this quickly. Looking forward to hearing from you!

    Thread Starter sam

    (@samjoelnang)

    Thank you so much for your assistance @thaikolja. The objective was to simply have Secondary Title read the <i> tag without affecting all of the words entered in the field. Say, if I only wanted to italicize an album title within a phrase, I would put therein This is an example Secondary Title that has an <i>Italicized Album Title</i> and the rest aren't, which will then show up on the single/actual post instead of the default title written as Artist Name - Italicized Album Title.

    I was able to finally achieve this through the ACF plugin’s text field functionality. It outputs the alternative title while recognizing the <i> tag wherever it is placed in the text field. I, however, decided to keep Secondary Title as I have several existing posts that have been assigned one (all required no italicization).

    What you do for the community is truly commendable. I appreciate every input you responded me with and your patience throughout! I find that code you wrote particularly useful for posts with titles already in headline form and needing italicization on certain words. I for sure will have some use for that.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.