Build Your Own Business Website header image

Welcome to our Members Only Forum

You are welcome to view the content on our Forum, just scroll down to view this forum post.
If you like what you find and want to be able to post a question, please check out our subscription options.
Please feel free to search the forum using either the Google Site Search above or the forum search below.

Avatar
Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Custom Content Length in the Blog Home page
Avatar
Lorenzo
Sarasota, FL

Founding Member
Members

Community Member
Forum Posts: 81
Member Since:
January 8, 2011
sp_UserOfflineSmall Offline
1
July 27, 2016 - 9:32 am
sp_Permalink sp_Print

Hi Rick,

Due to a conflict between Thesis 2.2 and dsIDXpress (an MLS plugin) I had to add some PHP code to customize the content on the Blog Home page. This is the current code:

function iif_custom_content_length ( $content ) {
if ( is_home ()) {
$content = get_the_content();
$trimmed_content = wp_trim_words( $content, 55, '...
<p class="blog_read_more"><a class="read_more_button" href="'. get_permalink() .'">Read More</a></p>' );
echo $trimmed_content;

}else {

return $content;
}

}
add_filter( 'the_content', 'iif_custom_content_length' );

 

Does that look correct to you?

Also, I need to add paragraph tags around the 55 character content. Right now it has not HTML tags around it.

Thanks for your help

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
2
July 29, 2016 - 10:11 am
sp_Permalink sp_Print

Lorenzo - you should try the extended excerpt box.  It will allow you to display the content (rather than the excerpt) and give you control over how much to display and what to show afterwards.

Avatar
Lorenzo
Sarasota, FL

Founding Member
Members

Community Member
Forum Posts: 81
Member Since:
January 8, 2011
sp_UserOfflineSmall Offline
3
August 1, 2016 - 9:14 am
sp_Permalink sp_Print

Hi Rick,

Thanks for the suggestion - love the box.

Unfortunately it doesn't work because of the Thesis - dsIDXpress conflict. The dsIDXpress plugin uses the blog home page template to display individual property pages. Hence I have to add the "Home Post Box - Content" to the Home template and then limit the words for the blog home page via the php.

Can you look at the above php and see if it can be improved upon by somebody who actually knows what he's doing 😉

Thanks again

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
4
August 2, 2016 - 8:27 am
sp_Permalink sp_Print

The code looks fine and while I didn't test it, I think it should work.

Avatar
Lorenzo
Sarasota, FL

Founding Member
Members

Community Member
Forum Posts: 81
Member Since:
January 8, 2011
sp_UserOfflineSmall Offline
5
August 3, 2016 - 12:35 pm
sp_Permalink sp_Print

Unfortunately it only works partially. It does shorten the paragraphs, but does not add the <p> tags AND

adds the first article excerpt twice. Once, correctly, as the first post displayed. And also right under the body tag. Please see screenshot below:

Image Enlarger

 

Any help would be greatly appreciated 🙂

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
6
August 10, 2016 - 10:25 am
sp_Permalink sp_Print

Why not come to one of the Wednesday sessions so I can see what is going on.

Forum Timezone: America/Los_Angeles

Most Users Ever Online: 228

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Keith W Jones: 1428

Brian Tozer: 1004

Carolin: 982

Heidi Hafner: 508

John Cunningham: 423

Reece Morrel: 353

Newest Members:

emma62755

sharonmarks

emma80233

Tijs de Jong

Daniel Frey

mutek

Forum Stats:

Groups: 8

Forums: 46

Topics: 6995

Posts: 34796

 

Member Stats:

Guest Posters: 6

Members: 6761

Moderators: 2

Admins: 2

Administrators: Rick Anderson, Rick Anderson

Moderators: Pierre Cote, Laura Nugent