WordPress.org

Ready to get started?Download WordPress

Forums

How to Format Post Titles like CopyBlogger (7 posts)

  1. AlexLakes
    Member
    Posted 4 years ago #

    Hi all,

    I'm trying to use break tags within post titles, but NOT anywhere else where the title is displayed. Does anybody know how to do this? I'm on 2.8.5

    For example, Copyblogger is a good example. Brian uses break tags within post titles, but anywhere else where the title is displayed, the break tag is automatically stripped from it. So the title flows everywhere it should.

    Please help! Thanks.

  2. AlexLakes
    Member
    Posted 4 years ago #

    Does anybody know how to do this?

  3. jvinch
    Member
    Posted 4 years ago #

    It could be he's inserting the title as a custom field including break and just uses the regular tag the_title elsewhere?

  4. AlexLakes
    Member
    Posted 4 years ago #

    Hi Jvinch, thanks for replying.

    You might be right. So maybe I could try removing the_title from post templates so it doesn't display there and then manually typing the title with breaks into the body field. That sounds like it would work.

    But I still wonder if there is an elegant solution that I'm missing. Like maybe putting something in functions.php to remove the break tags everywhere except within post itself, if that's possible. I don't know.

    Does anybody have the Thesis theme? How are your titles handled?

  5. jvinch
    Member
    Posted 4 years ago #

    AlexLakes,

    What I described above is a method where you would set a custom field (ie. called Special Title) in each post - and then call this value in your template.

    Let's say you create a custom field "special-title" - you'd call it in your template with

    <a href="<?php the_permalink(); ?>"><?php echo get_post_meta($post->ID, 'special-title', true); ?></a>

    This will produce a title that links to the permalink of your post, while displaying the value of your custom field. In the custom field, you'd place the title including the <br /> - I'm not sure if that would work, but it's the only way I could see this happen. Give it a try.

    I hope this helps!

  6. AlexLakes
    Member
    Posted 4 years ago #

    That's good. I just found that Chris Coyier posted a tutorial on your method around the same day that I first posted here. http://digwp.com/2009/10/custom-fields-for-html-post-titles

    BUT, a couple people replied to Chris (TeMc & Hiranthi) that there's a way to do it within functions.php so that it stays simple & maintenance free. They suggested using 'strip_tags' and if/else statements. But didn't describe enough detail for me to do it and haven't replied again.

    Here's what I think would work:
    strip_tags(the_title());

    Do you by chance know PHP well enough to pull this off with if/else statements?

  7. AlexLakes
    Member
    Posted 4 years ago #

    I figured it out! This shows the title without any html:

    the_title_attribute

    Now I just need to set it up to find and replace 'the_title' with 'the_title_attribute' within sidebars. I believe this is possible to select using 'is_active_sidebar'.

    Does anyone know enough PHP to set up a find & replace for this?

Topic Closed

This topic has been closed to new replies.

About this Topic