- This topic has 12 replies, 2 voices, and was last updated 3 years, 9 months ago by
David.
-
AuthorPosts
-
July 30, 2022 at 7:57 am #2298255
John
Good Morning,
I have created a custom post type and need entire post to show on the archive and related taxonomy pages but I also need just the excerpt on my normal posts, so I have that set in the GP customizer.
I found this filter:
add_filter( ‘generate_show_excerpt’,’tu_full_post_search’ );
function tu_full_post_search( $show_excerpt )
{
if ( is_search() )
return false;return $show_excerpt;
}So figured, (maybe stupidly) that I could add it in with an elements hook and then tell it only to work on those pages. However, when I try that the code shows on the front end and does not execute. I have tried it hooked in several different places and I have checked the box to say it’s code.
Are filters just not supported in elements, or am I doing something stupid?
I could put it in the child functions file with an if statement to check the post type, but I’m not sure where I would hook on the resulting function.
Thanks
JohnJuly 30, 2022 at 8:40 am #2298296John
Hi Again,
OK, found another entry that says filters don’t work in elements. Fair enough.
So now I’m trying to get it to work in my functions file, but no luck.
Now working on my staging site: https://staging-morganscloud.kinsta.cloud/tips/
This is what I have so far, but it does not change the tips archive to full content. Any pointers would be much appreciated.
add_filter( ‘generate_show_excerpt’,’tu_full_post_search’ );
function tu_full_post_search( $show_excerpt )
{
if ( is_post_type_archive(‘tips’)){$show_excerpt=false;
return $show_excerpt;}
}Intersecting thing is that just this changes the posts screen to full content but not the custom post tips:
add_filter( ‘generate_show_excerpt’,’tu_full_post_search’ );
function tu_full_post_search( $show_excerpt )$show_excerpt=false;
return $show_excerpt;
}July 30, 2022 at 8:47 am #2298303David
StaffCustomer SupportHi there,
are you using a Block element Content Template ?
IF so you can create one specifically for your CPT, and the use the Core Content Block to display the post content instead of the excerpt.
July 30, 2022 at 8:54 am #2298305John
Hi David,
Never done that before, but it sounds like a great way to solve it. I will dig in.
Big thank you for coming up on a holiday weekend. You guys are the best.
July 30, 2022 at 8:57 am #2298308David
StaffCustomer SupportMore info on Block ELement – Content Templates here:
https://docs.generatepress.com/article/block-element-content-template/
July 30, 2022 at 10:27 am #2298339John
Hi Again David,
Sorry, but two more issue.
It works but I can’t get the images to show when I insert a query block (either the GP one or the standard WP) when it
it’s on an elements block page : https://www.morganscloud.com/jhhtips/But it works fine if I just use it on a standard page: https://www.morganscloud.com/johns-tips-tricks-and-thoughts-2-1/
I wish I could use a standard page but I need an RSS feed and the breadcrums to take readers back to the archive for the CPT
The other thing is that on the elements page the posts are repeating three times
Any pointers would be much appreciated.
John
July 31, 2022 at 4:00 am #2298675John
Hi Again,
OK, I figured out why the images were not displaying: something stupid I did years ago in CSS. I can fix that.
But I’m still perplexed by why the posts are showing three times: https://www.morganscloud.com/jhhtips/
Again it might be something stupid I’m doing, but if you have any pointers on where to look I would appreciate it.
Thanks
JohnJuly 31, 2022 at 4:07 am #2298681John
Hi Yet Again,
Oh dear, it looks like I can’t use the query loop on a archive template: https://generatepress.com/forums/topic/archive-page-with-query-loop-added-via-content-element-displays-posts-repeatedly/
Has that been changed/fixed in some way, since I think that’s what you recommended above. Or did I just misunderstand.
Anyway, looks like I’m back to square one and need to figure out how to force the tips archive to show the entire content while the normal posts just show excerpts.
Any advice appreciated.
John
July 31, 2022 at 5:45 am #2298726David
StaffCustomer SupportYou don’t use a Query Loop, in the Block Element – Content Template, as youre adding a Loop inside a Loop 🙂
1. Create a new Block Element,
2. Set the Element Type to Content Template.
3. There is a list of Templates to choose from, select one for a quick start.
4. Inside the template you just added, insert a Content Block.
5. Set the Display Rules to apply to the relevant archive.July 31, 2022 at 5:59 am #2298742John
Hi David,
I only have one thing to say….Duh!
Why didn’t I think of that…don’t answer that.
I need to dig-way deeper into all the cool stuff GP does, a particularly since I suck as a coder.
Seriously, thank you!
July 31, 2022 at 6:37 am #2298777David
StaffCustomer SupportYou’re welcome – and we are looking at ways to make this kind of thing way more accessible, as today they are complicated things to work with 🙂
July 31, 2022 at 11:22 am #2299106John
Hi David,
The key thing is that I have been in WP for 15 years so I tend to fall back on code, even though I suck as a coder, and not realize that there are easy, but still light, ways to do things without code. The other thing is I kinda thought that the standard block editor would give me everything I needed without realizing how far ahead generate blocks/elements is. Just about to buy pro, now I know better.
And the final point I learned is that GB support’s most valuable attribute is not “this is how to do it” but rather “wait, here’s a better way”. That’s priceless for someone like me who is primarily a content creator with a business to run (membership) not a developer.
Thanks again.
August 1, 2022 at 3:20 am #2299493David
StaffCustomer SupportThank you for your kind words John, it really is appreciated, and it always make me happy to hear we are getting things right!
Have a great day!
-
AuthorPosts
- You must be logged in to reply to this topic.