• Resolved Doodlebee

    (@doodlebee)


    I’ve gotten around this before with some CSS, but it’s not working for me this time.

    Basically, what I need is, in the title section when I create a post, I need to keep my posts grouped together by month, So I’ve been putting in (for the title) “November 2006 – post title”. Then, in the body area, the first line I add is the actual name of the post: “post title”. This way, when I do certain things, I can easily see which posts go with what month. I use CSS to hide the actualy title, and place h1 tags around the one with in the body and style that one ot be shown.

    This has worked great so far – I can have the actual title be something completely different than what shows on the page as the main header (came in really handy when I had a site that needed the sidebar linsk to simply say “About” but they wanted the page header to say something compeltely different). However, now I’m running into an inssue that this workaround *can’t* fix.

    So is there a way I can somehow add a secondary title field between the post title field that’s already there, and the body field? It doesn’t necessaily have to be a new field in the admin area – although that would be nice – but just some way, perhaps in the mina index template by using some kind of PHP call, I could get that secondary header?

    I have an alternate workaround, but it’s way ugly, and I’d rather avoid it if there’s a better way.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Can’t you use custom fields for this?

    Couple ways I can think of to do this.

    First method is a bit of PHP which parses “November 2006 -” from your post title and displays just “post title”:

    <?php
    $post_title = preg_replace('/^w+ +d{4} +-/', '', get_the_title());
    echo apply_filters('the_title', $post_title);
    ?>

    The preg_replace() stuff can be a little much for the uninitiated, but basically it performs an expression match on “MONTHNAME YEAR -” and replaces it with an empty value. Then the echo line (which outputs the suffixed post title) passes the $post_title var through the WordPress function apply_filters() so any WordPress or plugin title filters are run it first.

    Second method is more attune to the WordPress Way: Enter the “post title” as a custom field.

    Using ‘title’ as your key, and the real title for a post as the value, you can implement the following in your templates to collect and display the ‘title’ custom field:

    <?php
    $post_title = get_post_custom_values('title');
    echo apply_filters('the_title', $post_title[0]);
    ?>

    get_post_custom_values() returns the value(s) of the ‘title’ meta key to $post_title. The second line should be familiar, but $post_title is now an array (you can have more than one custom field with the same key attached to a post). So we specify the first array key/value with $post_title[0].

    EDIT: Yes, vkaryl. Yes you can…

    Heh…. thanks. I never really know, ’cause I’ve never used them – but it did seem logical (oh, yeah, I KNOW someone’s going to laugh about the juxtaposition of “vkaryl” and “logical”….)

    Thread Starter Doodlebee

    (@doodlebee)

    Oh Good Lord. I’m an idiot. If you could see my face right now…

    Thanks a bunch guys 🙂

    (thinks there should be an option up there for “resolved due to discovery of exactly how stupid the original poster was” – or maybe “resolved due to ‘DUH’ moment”)

    *laughing* doo-bee…. the only ones who would ever use it would be the 2 or 3 of us who are female….

    I dunno. I’ve had my share of DUH moments…

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘two post titles?’ is closed to new replies.