Skip Navigation

[Resolved] I need help to get my post type to show on my home page when I insert the fields

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 22 replies, has 2 voices.

Last updated by amyM-2 5 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#1231911

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Amy,

That is ok. Let me walk you through the steps.

So we have the custom code here:


add_shortcode('trim', 'trim_shortcode');
function trim_shortcode($atts, $content = '') {
$content = do_shortcode($content);
$length = (int)$atts['length'];
if (strlen($content) > $length) {
$content = substr($content, 0, $length) . '…';
}
return $content;
}

So this generates the shortcode [trim length="20"] [/trim]

Now to use this you need to add it to the Toolset Custom Code section in Toolset -> Settings -> Custom Code and hit Add New.

Then give the snippet a name. Now just add the code to the area and hit save and ensure that it is activated.

Once you have done this then you can now use this with your code.
[trim length="20"] [types field='heroic-acts'][/types][/trim]

Please let me know if further clarity is needed.

Thanks,
Shane

#1231913

I did everything you said, but it didn't work.

#1232287

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Amy,

You actually did it correctly and it works fine.

The issue was that you only wrapped one of the shortcodes that you were using to display the content in the trim shortcode.

Have a look now.

Thanks,
Shane

#1232318

I changed the word number from 20 to 10 and now it's not working....

#1232340

it's driving me crazy

#1232373

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Amy,

I must apologize for this bring so frustrating for you but I can reassure you that it actually works. I had setup an example for you but it seems that it was removed.

However the correct way to do it is like this.

[trim length="20"] {!{types field='infilt-bullet-points'}!}{!{/types}!}[/trim]

[trim length="20"] [types field='heroic-acts'][/types][/trim]

It should be noted that the texts are not trimmed based on the words but rather based on the number of letters. So if you use 20 after the 20th letter then nothing else will be displayed.

I suggest using 200 .

Thanks,
Shane

#1232418

I am such a dork!!! I was totally not putting the code in between the code you gave me!!!!

YOU ARE AWESOME!!! Thank you so much!!!

#1232419

My issue is resolved now. Thank you!