• Resolved coockie92

    (@coockie92)


    Hello, I’ve recently started using wordpress itself,and choose Appointment as my first theme, but I’m having issues editing functions.php file in order to change length of latest posts showing in the news section of my site. All of the posts there end mid-word and I cannot set proper length for all of them at once. Is there a way to configure it in such a way that the read more button appears at the end of for ex. 3’rd sentence or adding a tag in a post to set the “show more” point?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi

    Plz share your website URL.

    and please indicate snapshot image.

    Thanks.

    Thread Starter coockie92

    (@coockie92)

    My Website’s link is” https://codemax.ddns.net.

    I have also used “<!–more–>” code in my post and no difference was made, I will provide a screenshot in a second.

    <Screenshot

    Hi

    If you changes text length of latest news section find below code in function.php

    function get_home_blog_excerpt()
    	{
    		global $post;
    		$excerpt = get_the_content();
    		$excerpt = strip_tags(preg_replace(" (\[.*?\])",'',$excerpt));
    		$excerpt = strip_shortcodes($excerpt);
    		$original_len = strlen($excerpt);
    		$excerpt = substr($excerpt, 0, 145);
    		$len=strlen($excerpt);
    		if($original_len>275) {
    		$excerpt = $excerpt;
    		return $excerpt . '<div class="blog-btn-area-sm"><a href="' . get_permalink() . '" class="blog-btn-sm">Read More</a></div>';
    		}
    		else
    		{ return $excerpt; }
    	}

    edit this code ‘$excerpt = substr($excerpt, 0, 145);‘ and changes text
    content value, like 145 to 100.

    Then save the change.

    Thanks.

    Thread Starter coockie92

    (@coockie92)

    Alright, so thru experiment i found first number in this function is number of signs to skil from the beginning and the second one is the sign number to end on. Thanx to that I can set post length to a static numbet to end on a specific place in my post. But this still doesnt’t satisfy my needs. Other posts are going to have different placements for end of my intro. I want this length to be dynamic, depending on the <!–more–> tag in my post. I bet this is a difficult task, but i hope mayby there’s that function in Appointment theme?

    Hi

    For this find below code in index-news.php

    <p><?php echo get_home_blog_excerpt(); ?></p>

    and replace with below code

    <p><?php the_content(); ?></p>

    then save and change.

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Editing Latest news post length.’ is closed to new replies.