Community Forums › Forums › Archived Forums › Design Tips and Tricks › Blog page first post not being modified by filter function
Tagged: excerpt_more filter hook
- This topic has 11 replies, 3 voices, and was last updated 9 years, 8 months ago by Lauren @ OnceCoupled.
-
AuthorPosts
-
August 9, 2014 at 9:45 pm #118016clareMember
Hello,
I have set a blog page that is separate from my static home page.
I have modified the "[...]" link that comes after each post's snippet by using a filter function. To do this, I used WordPress's "excerpt_more" hook.add_filter('excerpt_more', 'new_excerpt_more'); function new_excerpt_more($more) { global $post; return '... <br clear="all"/><a class="moretag" href="'. get_permalink($post->ID) . '">Continue Reading</a>'; }
The problem I am having is that, for some reason, this works for every post, except the very first post of the blog page. Is there something different or special about the very first post of the blog page that would make it not go through this filter hook?
Thank you very much for any help.
August 9, 2014 at 10:42 pm #118022Genesis DeveloperMemberAre you using magazine template? Can you give your site URL?
August 10, 2014 at 6:53 am #118043Lauren @ OnceCoupledMemberThere are three ways (that I know of) to create excerpts, so you need to change the output for each of these functions. I use:
//* For using the WordPress More Tag to break a post add_filter( 'the_content_more_link', 'sp_read_more_link_tag' ); // * For using the Content Limit on the Content Archives section of Genesis Settings add_filter( 'get_the_content_more_link', 'sp_read_more_link_limit' ); // * For using "the excerpt" in Genesis Settings or Genesis Featured Post widget add_filter( 'excerpt_more', 'sp_read_more_link_limit' );
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
August 10, 2014 at 9:12 am #118066clareMemberI'm sorry, I should have included some more information in my original post.
I am using the Enterprise Pro child theme version 2.0.1 and WordPress version 3.9.2.
genwrock, I am not sure what the "magazine template" is. I am sorry but I cannot give a direct link, not because I don't want to, but because it's a development site that is password protected. However, I have attached a screenshot of the blog page to give you a look at what I am babbling about.
Lauren, the function I have created, using the_excerpt() hook, is working for every blog post except the first blog post. So because it is working, I do not think I need to be creating more functions.
I have a feeling that there really is something special or unique about the first post on the blog page in the Enterprise Pro theme, because I have counted the words in each excerpt on my blog page. Every excerpt has 55 words, which I know is the default size for the excerpt by reading this page . However, the very first blog post on the blog page is 86 words, which is longer than the default 55 words. I have not changed the default size of the excerpt. Why is this the cause only for the first blog post on the blog page? It seems that something is going on that processes the first blog post differently than every other blog post.
And thank you again for any input or advice on this baffling issue.
August 10, 2014 at 9:50 am #118069clareMemberI tried to post a link to a screencap of my blog page, but for some reason the forum is not letting me post links. I even used the "link" toolbar button. I guess I do not have enough forum posts yet to post links.
August 10, 2014 at 9:53 am #118070Genesis DeveloperMemberThen it is very odd and a strange thing is happening on your site. I think that you're using 'Blog' template for your blog page. And then you set the excerpt option from Content Archives drop down (Genesis -> Theme Settings -> Content Archives Section). Am I right?
August 10, 2014 at 10:45 am #118081clareMemberYes, Genesis->Theme Settings-->Content Archive section has a drop down menu in which I have selected "Display post excerpts".
For the actual blog page, if I click on "edit page", in the Page Attributes section, the Template is set to Blog.
As I was saying before, the excerpts for every single blog post work perfectly...except for the first blog post.
August 10, 2014 at 1:34 pm #118086Lauren @ OnceCoupledMemberCan you share your blog template code? It sounds like your first post isn't displaying an excerpt, which could be caused by using the Genesis Grid Loop, only you said you wrote your own template, using "the_excerpt()" for all of your posts?
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
August 10, 2014 at 2:50 pm #118094clareMemberI am using the Genesis child theme Enterprise Pro 2.0.1. I did not write this template, StudioPress did 🙂
The code I posted above is just a filter that I added to the "excerpt_more" filter hook. It modifies the default [...] that comes after a blog post excerpt, and instead replaces it with a link that says "Continue Reading".
The first post is definitely showing some sort of excerpt. It is certainly not the full post. The length of the excerpt for the first blog post is 86 words (more than the standard 55 words). The length of the full post is 695 words. So clearly, it is some kind of excerpt.
Ok I just checked, and what the first blog post excerpt is showing is the first complete paragraph of the post.
August 10, 2014 at 3:15 pm #118101Lauren @ OnceCoupledMemberSorry Clare, I misinterpreted the statements "the function I have created, using the_excerpt() hook" and "the very first blog post on the blog page is 86 words."
It's not an issue of the template by default. Without being able to see any of your code, my suggestion would be to make sure it's not any of your plugins. You could also try changing themes, or removing changes that you've made, to systematically determine where that is coming from.
Best,
Lauren
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
August 10, 2014 at 10:50 pm #118136clareMemberWhat code would you need to see? I would be happy to provide it if I can.
August 12, 2014 at 4:09 pm #118464Lauren @ OnceCoupledMemberIf you have a blog template file, that would be the first place I looked. Second would be the functions file.
Did you try disabling plugins, switching themes, or temporarily removing template files in order to isolate the issue?
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.