• Is there a way I can call only part of a title? I’ve Googled and searched the forum to no end. For instance, on a post titled… Part 1: Blah Blah Blah I want to call only the Blah Blah Blah for an update section on the front page. Is this possible?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Dandelion Cake,

    This isn’t possible in the manner you are requesting, however you might try truncating or shortening the title with the “Part 1” at the end of it. Something like this:

    <?php if (strlen(the_title('','',FALSE)) > 25) {
                  $title_short = substr(the_title('','',FALSE), 0, 25);
                  preg_match('/^(.*)\s/s', $title_short, $matches);
              if ($matches[1]) $title_short = $matches[1];
                  $title_short = $title_short.' ...';
              } else {
                  $title_short = the_title('','',FALSE); } ?>
    
        <h2><?php echo $title_short ?></h2>

    The above will shorten the title length to 25 characters and end it with “. . .”

    The only other option is to create a category titled “Part 1:”, add the post into this category and finally call on that category title only to appear when on the Post page or when it is needed like this:

    <h2><?php echo get_the_category_by_id(5); ?> <php the_title(); ?></h2>

    In the above instance category 5 is titled “Part 1:”

    Thread Starter dandelion-cake

    (@dandelion-cake)

    Thanks so much for the reply but that won’t work for what I’m trying to do. How about this… is there a way for me to get the count of each post in a category? Not the count for the entire category, but say there’s 5 posts in a category and I want to number them: 1 (the first post posted in that category), 2 ( the 2nd post posted in that category), etc. Hope this makes sense?

    Dandelion Cake,

    So you’re looking to simply number the the posts? You could place them in an ordered list with a class and simply add some styles to the class.

    <ol class="numbers">
    <li><?php the_title(); ?><?php the_content(); ?></li>
    </ol>

    This is the easiest method.

    Thread Starter dandelion-cake

    (@dandelion-cake)

    I’m not sure if what I want is even possible. I’ll give you the link so you can see what I’m trying to do.

    https://www.dandelioncake.com/

    At the top of the page, you’ll see a little updates thing where it says: Part 4 of Ruben’s Hollow (A Dark Heart) was posted on 07/31/2009. Until I added this, I had the individual posts in that category titled for instance… Part 4: A Dark Heart. But it wouldn’t look right on the main page to have: Part 4 of Ruben’s Hollow (Part 4: A Dark Heart)… so I took the “Part X:” out of the titles. But on the RH page itself:

    https://www.dandelioncake.com/rubens-hollow/

    I’d like the titles to still say Part 1, 2, 3 and 4 etc so people will not be confused as to their order. If I can call the individual category post counts, I can simply put something like Part <?php this categories individual post count ?>: before the titles on the custom template for Ruben’s Hollow.

    Lordy… did I make that clear? *cries*

    Dandelion Cake,

    Not sure if I caught this a few days too late but I’m not seeing the updates on the main page. I assume this home page update was just a recent posts notice? If this is the case why not put all the Rubens Hollow posts under a Rubens Hollow category and allow the posts to display under it. I must be missing something else though.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Only Part Of A Title’ is closed to new replies.