• Resolved tuhinbiswas98

    (@tuhinbiswas98)


    i want to know ther any way to Limit Characters of related post Title ? i want to show 9 related post but its not looking good some of my post title long and some post title short that why i want to Limit Characters in related post Title but not in my home page only in related post

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter tuhinbiswas98

    (@tuhinbiswas98)

    its wp-content/themes/your-child-theme/related-posts.php with other file like functions.php.style

    OK. That’s not where it goes. If you look back through this thread you’ll see that I’ve mentioned 3 times that it needs to go in the same folder that it’s in for the parent theme, which is not the same folder as all the other child theme files. It should be in wp-content/themes/your-child-theme/inc/. If you move the related-posts.php file to the correct folder in your child theme it should work.

    Thread Starter tuhinbiswas98

    (@tuhinbiswas98)

    oh sorry sorry i am realy new and not good at eng ?? sorry but you now i can see this this is a test befor my related posts name now what i have to do to Limit Characters in related post Title?

    Thread Starter tuhinbiswas98

    (@tuhinbiswas98)

    i try all that code you give to to do that but stil non of them worrking :O

    OK, so now we know it’s using the file in the child theme. Next is to edit that file. Find this section:

    this is a test <h4 class="post-title">
    	<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    </h4><!--/.post-title-->

    and change this at the end of the line (the last instance, not “title=”):

    <?php the_title(); ?>

    to this:

    <?php echo wp_trim_words( get_the_title(), 5 ); ?>

    You’ll need to change your post titles so they are several words instead of a string of characters. See if that works. If it does, then go back and remove the “this is a test” text that you added and test it again. If that looks good you can adjust the number of words as needed and you should be set.

    Thread Starter tuhinbiswas98

    (@tuhinbiswas98)

    ok i try it now it worrking fine ty ty for help ??

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Limit Characters in related post Title’ is closed to new replies.