• Hi! Anyone know of a way to auto-detect a line-break within a loop, and insert an image there?

    I have a loop in the header of this site with an auto-feed of post-titles from a category listed with snow-flakes in between. However, when the line breaks after a snowflake, the next line has none…

    Here’s the link to the site:
    https://themusicfest.com/test/

    And, the current loop coding:

    <?php query_posts('category_name=artists' .'&posts_per_page=50' .'&orderby=title&order=ASC'); ?>
    <?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 echo str_replace (' ', '&nbsp;', get_the_title()); ?></a>
         <?php endwhile; ?> <?php endif; ?> <img src="/test/images/snowflake.png">

    Ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Initially was going to suggest that you do a str_replace and stuff.

    BUT I can’t reconcile the code you have posted with what is on the website. Replacing spaces in the title text with non-breaking spaces i.e. ” ” is not happening, and more.

    How about something like this:

    $brflag = can see "<br" in text
    ... later on
       if( $brflag ) echo starflake;

    Are you referring to the band/artist names? If so, could you not put the post titles into an inline list and set the snowflakes as the bullets in css?

    Something along the lines of;

    <?php if (have_posts()) : ?>
    <ul>
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    <?php endif; ?>
    Thread Starter BackstageDS

    (@backstageds)

    I think that making it a list is the ticket… However, do you know of a way to make the list stay in-line, centered, with the bullets, and with the snowflake-bullet after the final title?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding image at beginning of line-break in loop’ is closed to new replies.