• Hello Guys, I was trying to bold part of the post tittle before “:” and I used thse customs, but for some reason it doesn’t work. Do you know what am I doing wrong?

    It should looks like this
    Name of Person:
    Sentence he said

    I added this to style.css

    .entry-title span { font-weight: bold; }

    and this to functions.php

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

    Also, I would like to start Text after “:” below the name of Author
    Website is Odviati.com

Viewing 8 replies - 1 through 8 (of 8 total)
  • your function is not complete try this code, and in the post editor find the “Publish” section. Next to “Visibility” click on edit and then check the “Stick this post to the front page” option there.

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

    (@pcolkin)

    I think that still doesn’t work :/

    Thread Starter pcolkin

    (@pcolkin)

    Actually, it is in different font.
    I want to have all posts be like this. Does it mean that I need to stick every post to the homepage?

    yes couse in your function you have condition to chek if is stick or not is_sticky(), or you can modify you`r function code with something like this

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

    Thread Starter pcolkin

    (@pcolkin)

    That works now! But unfortunatelly it does not change at Homepage, only in opened article. And it looks like this :/

    https://oi58.tinypic.com/zkjz1x.jpg

    you seem to be styling h1 span, but on the home page, the part before the colon is in a h2 a span .

    try using a browser inspection tool to find out more …

    Thread Starter pcolkin

    (@pcolkin)

    Sure, is there any solution to make it work for h2 at homepage and h1 in opened post?

    try

    h1 span, h2 a span { font-weight: bold; }

    please make the site live again if you would get more suggestions for the formatting.

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