Community Forums › Forums › Archived Forums › Design Tips and Tricks › Why doesn't the Post Info code snippet not work?
Tagged: .post-info, code snippet, Function.php
- This topic has 7 replies, 2 voices, and was last updated 10 years, 4 months ago by
Carla the Moose.
-
AuthorPosts
-
May 12, 2013 at 8:42 pm #40608
Carla the Moose
MemberI deleted the Simple Edits plugin and added this code from the Code Snippets page to my functions.php file:
`/** Customize the post info function */
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
if ( !is_page() ) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}}`Before I made any changes, I uploaded it and refreshed my website. But I got a white page. I thought you can simply paste the code snippets into the functions file without any problems. But this is the second time I've encountered a problem.
Any suggestions? My website isn't public right now. Can this be tested without having access to my website? I'm using the eleven40 theme.
Thank you!
May 12, 2013 at 8:53 pm #40611Carla the Moose
MemberI wanted to add:
I'm using the Simple Hooks plugin, but I intend to delete that one, too, once I get everything working in my functions file.
Thanks!!
May 12, 2013 at 9:49 pm #40614Bill Murray
MemberGenerally speaking, you can paste code snippets, provided you do it correctly. The code snippets are pretty reliable; if there were an error, I'd bet that it would be promptly fixed.
If you're not familiar with PHP, even a small typo can break your site. So you may find it safer to stick to Simple Edits.
You also said you're using Simple Hooks. Did you put the code in your child theme functions.php? Or in Simple Hooks?
On a quick look, the code itself seems fine. You'd paste the code after the starting tag. Normally, at the end of the file works well. Don't paste it in the middle of an existing block of code.
If you're still having trouble, you can get your site back up by replacing your broken functions.php with a known good one. Then, to resolve your question, you can paste your functions.php to a Pastebin and paste the link in this thread.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
May 12, 2013 at 10:05 pm #40615Carla the Moose
MemberThanks for your feedback. Here's the Pastebin link for my function file: http://pastebin.com/5ZQ4K2Kw
I'm using Simple Hooks to customize post info while I figure out how to get the code snippet to work. I only pasted the code into my functions file.
I don't see anything in the function I added to my file that would cause the white page. It's easy enough restoring my website by removing the snippet, but I'm not sure why this created a problem.
May 12, 2013 at 10:49 pm #40617Bill Murray
Member1) You have a number of modifications in that file. Were those modifications working prior to this change? In other words, if you delete only lines 164-171 of the file, does your site function normally?
2) I think you have to decide whether you'll use Simple Hooks or code in functions.php to modify postinfo. If you're going down the path in this thread, you'll have to remove the code in Simple Hooks and not load anything else related to postinfo. It's too hard to debug with competing sets of code trying to change the same thing. If you've tested #1, ditch the postinfo code in Simple Hooks, put the code in question back into your functions.php per the Pastebin, give it a shot, and post the results.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
May 12, 2013 at 11:06 pm #40618Carla the Moose
MemberI showed you my functions file with the code snippet included. I removed that snippet as soon as I realized it was causing an error. So my actual file doesn't include that section of post-info code.
Nothing is competing with the Simple Hooks plugin. Just pretend I'm not using that plugin. Sometimes when I ask for support, I'm told to use a plugin, and I always have to make it clear that my objective is to avoid them. That's the only reason I mentioned it. I've edited my post-info via the plugin, since the code snippet gave me a white screen. I never use both at the same time.
Everything in my functions file works. The only problem was the post-info code snippet.
May 12, 2013 at 11:16 pm #40619Carla the Moose
MemberWhen you mentioned I have a lot of functions in that file, it triggered a thought. So I browsed the other functions and may have found the issue. I'll post back here in a second.
May 12, 2013 at 11:21 pm #40620Carla the Moose
MemberHa! It worked.
I found the same code snippet in my functions file, but specific to changing the comment link text. It used the same filter and was identical to the post-info snippet, except it only included code for the link.
I removed that snippet, made my changes to the post-info snippet, and it worked.
Thanks for jumping in and lending a paw. If you hadn't mentioned the other functions, I wouldn't have given any thought to reviewing them for a possible conflict.
Much appreciated!
-
AuthorPosts
- The topic ‘Why doesn't the Post Info code snippet not work?’ is closed to new replies.