• I’ve created an auto-feed of post titles from a specific category, and am looking for a way to make each individual title not wrap to the next line. If a single title is too long to fit on a line, I’d like them to move to the next line. Here’s the current coding:

    <?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    <img src="/test/images/snowflake.png"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title() ?></a>
         <?php endwhile; ?> <?php endif; ?> <img src="/test/images/snowflake.png">

    and the css:

    .lineup {
      font-size: 28px;
      font-family: "StationNoOne";
      color: #453325;
      text-transform: uppercase;
      line-height: 1.5;
      text-align: center;
      width: 940px;
      margin-left: 37px;
    }

    and the site is here:
    https://themusicfest.com/test/

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The “easy” way to do this is like this.

    Instead of:

    <?php the_title() ?>

    Use this:

    <?php echo str_replace (' ', '&nbsp;', get_the_title()); ?>

    What that does is replaces any spaces in the title with no-breaking spaces. That should force every name to be on the same line. I haven’t tested this, but I am 99% sure that it’ll work the way you want it to.

    Thread Starter BackstageDS

    (@backstageds)

    YOU ARE MY HERO! That worked!! ??

    Next question…. if you go check the site, there are snowflakes between the post titles, and now that they wrap, we have some spaces that need an extra snowflake added at the beginning of some of the lines.

    Any solutions to fix?

    That one’s a lot harder. Because there’s no clear line end marker there’s no easy way to find out where something should go.

    There’s a few ideas here, but I haven’t tried any of these before, so I can’t verify what works. This may be something that you’ll need to spend some time searching around for, unless someone else here has any experience with this situation.

    Thread Starter BackstageDS

    (@backstageds)

    oof. the stuff in the link probably works, but it’s over my head. I’ll post a new thread for that specific question.

    Thanks a ton!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Category Post Titles Loop without Line Breaks’ is closed to new replies.