• Resolved sundas

    (@sundas)


    hi, i have posts in the pinboard theme which when marked sticky becomes the slideshow on the main page and the post title becomes the slide title

    Is there any way i can make part of that title bold to differentiate between the words the come after the colon in the title e.g make

    “Spirit of the Awakened Warrior: The Keys to Accelerate Your Growth and Blessings”

    this, that is the part before the colon bolded

    Spirit of the Awakened Warrior: The Keys to Accelerate Your Growth and Blessings”

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try creating a child theme first. Copy slider.php to your child theme and change this:

    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

    to this:

    <?php
    $title = get_the_title( $post->ID );
    $new_title = '';
    // get title before ":";
    $before = substr( $title, 0, strpos( $title, ':' ) );
    if ( $before ) {
    	$new_title .= '<strong>' . $before . '</strong>' . stristr( $title, ':' );
    }
    $title = ( '' != $new_title ) ? $new_title : $title;
    ?>
    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php echo $title; ?></a></h2>

    Thread Starter sundas

    (@sundas)

    it doesnt help, doing what you said makes the whole of the slider title bold and worse messes with the drop down menu, instead of dropping down all menu items become a part of the menu tabs and the top alignment gets messed up as well..

    see link below for better understanding

    Thread Starter sundas

    (@sundas)

    Thread Starter sundas

    (@sundas)

    and it also undoes the changes like background image

    totally alternative approach:

    add this filter to functions.php of your theme or child theme:

    add_filter( 'the_title', 'bold_before_colon' );
    function bold_before_colon( $title ) {
    if( is_sticky() && strpos( $title, ':' ) ) $title = '<span>'.preg_replace('#(:)#',':</span>',$title,1);
    return $title;
    }

    add this line to style.css of your theme or child theme:

    #slider .entry-title span { font-weight: bold; }
    Thread Starter sundas

    (@sundas)

    didnt work, I added the filter to functions.php on the first line and added the css code but the whole title becomes bold instead of just the part before colon ??

    I see it working in the web page you have linked earlier; IE8 and FF20

    try to clear the browser cache, with ‘CTRL F5’ or (several) ‘reload’

    Thread Starter sundas

    (@sundas)

    omg! thankyou sooo very much Mr. alchymyth! it is working, thanks alot i could not have figured it out myself! really thanks a bunch

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘how to bold part of the post title’ is closed to new replies.