• Trying to get the title placed on the same line as the label, i.e

    Label: Title

    Currently it’s formatted as:

    Label:

    Title

    <p>
    <?php echo apply_filters('cm_tooltip_parse', 'Label: ', true); ?>
    <?php if ( generate_show_title() ) {
     the_title();
    }
    ?>
    </p>

    Also tried:

    <p>
    <?php echo apply_filters('cm_tooltip_parse', 'Label: ', true);
    if ( generate_show_title() ) {
     the_title();
    }
    ?>
    </p>

    Is the filter code causing any issues here

    Thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Use the following codes:

    
    <p>
    <?php echo apply_filters('cm_tooltip_parse', 'Label: ', true);
    if ( generate_show_title() ) {
     the_title('<span>', '</span>');
    }
    ?>
    </p>
    

    OR

    
    <p>
    <?php echo apply_filters('cm_tooltip_parse', 'Label: ', true);
    if ( generate_show_title() ) {
     get_the_title();
    }
    ?>
    </p>
    
    Thread Starter ratamatcat

    (@ratamatcat)

    Hey Jogesh,

    I’m still getting getting the break unfortunately but thanks for checking this

    It’s weird because it not only breaks to a new line but has the space too, like a double break

    Moderator bcworkz

    (@bcworkz)

    the_title() only outputs the title and nothing else, no line feeds, no HTML, nothing else. However, it is filterable, so conceivably your theme or a plugin is adding extra output. More likely the line feeds are due to the tooltip filter.

    You may be able to fix up the line feed with CSS if it’s due to “Label:” being styled as a block instead of as inline. We’d need to see a live page demonstrating the problem to advise in more detail about this possibility.

    Maybe try:

    <p>
    <?php $title = generate_show_title() ? get_the_title() : '';
     echo apply_filters('cm_tooltip_parse', "Label: $title", true); ?>
    ?>
    </p>

    I’ve no idea what ‘cm_tooltip_parse’ does so this approach may not work as desired. Wouldn’t hurt to try though.

    Or could you do away with the filter and generate tooltip code or whatever the filter does through your own means? Or assign the filter return to a variable and strip out offending content with str_replace() prior to output?

    Thread Starter ratamatcat

    (@ratamatcat)

    That’s really neat. Label and Title are placed on the same line with this. Tooltip still works.

    There is now an unwanted space below that as you say is likely caused by the tooltip filter, i.e.

    Label: Title

    line 2 text info
    line 3 text info
    line 4 text info

    instead of what I want which is:

    Label: Title
    line 2 text info
    line 3 text info
    line 4 text info

    I am waiting on the tooltip plugin supports reply to this.

    great thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Text forcing new line’ is closed to new replies.