- This topic has 5 replies, 2 voices, and was last updated 8 years, 8 months ago by Tom.
-
AuthorPosts
-
August 23, 2015 at 12:29 am #131481Reuben
Hi there,
I’m currently using the normal blog format for the ‘post’ post type while I use the masonry for other custom post types. I wish to invoke the Excerpt view for masonry posts while the ‘post’ post type gets the full view. Is there any way to do so?
In addition, for the excerpt view, is there a way to enable emojis? For some reason, they are being stripped out in excerpt view.
Thank you!
August 23, 2015 at 10:59 am #131549TomLead DeveloperLead DeveloperHi there,
This is a tough one, there’s a way we can trick the post into using the more tag filter or not, but it’s not ideal.
I need to add a filter so we can choose to use the excerpt or full content in certain situations.
For example:
add_filter( 'generate_more_tag', 'generate_force_excerpt' ); function generate_force_excerpt() { if ( 'your-post-type' == get_post_type() ) { return 'false'; } else { return 'true'; } }
Basically, that checks to see if we’re on your post type – if we are, it will show the excerpt.
If we’re not, it will trick the post into thinking the more tag is being used, so it will use the full content.
Not ideal, but should work.
August 23, 2015 at 4:00 pm #131585ReubenHi Tom,
I tried using this:
add_filter( 'generate_more_tag', 'generate_force_excerpt' ); function generate_force_excerpt() { if ( is_post_type_archive( array( 'products', 'retailers' ) ) || is_tax( 'database' ) ) { return 'true'; } else { return 'false'; } }
But now the full post shows on each and every post, no matter whether I have the excerpt enabled or not. Am I doing something wrong?
Thanks for the quick help by the way ๐
By the way, am I right to say that the excerpt stripping out Emojis is due to WordPress and not the theme?
August 23, 2015 at 11:58 pm #131601TomLead DeveloperLead DeveloperWhat the above code should do is if anything in your first if statement is true, it will show the full post regardless of any other setting.
For anything that isn’t true in that statement, it should show the excerpt – is that not what’s happening?
That’s correct – WordPress filters out any and all HTML in the excerpt function.
There are ways to allow certain HTML in the excerpt, but it’s a little complicated: http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt
Bit late here now, but take a look at the above and let me know if you need clarification on anything ๐
August 24, 2015 at 6:09 am #131665ReubenThanks for the quick replies!
I tried this code
add_filter( 'generate_more_tag', 'generate_force_excerpt' ); function generate_force_excerpt() { return 'false'; }
But it still never shows the excerpt. Changing it to return ‘true’ does nothing as well.
August 24, 2015 at 8:54 am #131695TomLead DeveloperLead DeveloperChanging that to true should force all posts to show the full post.
For example, here’s a situation where the user wanted the most recent post to be full, while the others were excerpts: https://generatepress.com/forums/topic/showing-newest-post-in-full-on-index-pages/#post-127836
Having it set to false will disable the more tag functionality, but won’t necessarily do anything else depending on the Blog Content setting you have.
-
AuthorPosts
- You must be logged in to reply to this topic.