Why doesn't the Post Info code snippet not work?

Community Forums Forums Design Tips and Tricks Why doesn't the Post Info code snippet not work?

This topic is: resolved

This topic contains 7 replies, has 2 voices, and was last updated by  WiggleChicken 1 year, 3 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #40608

    WiggleChicken
    Participant
    Post count: 163

    I 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!

    #40611

    WiggleChicken
    Participant
    Post count: 163

    I 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!!

    #40614

    Bill Murray
    Participant
    Post count: 575

    Generally 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.

    #40615

    WiggleChicken
    Participant
    Post count: 163

    Thanks 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.

    #40617

    Bill Murray
    Participant
    Post count: 575

    1) 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.

    #40618

    WiggleChicken
    Participant
    Post count: 163

    I 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.

    #40619

    WiggleChicken
    Participant
    Post count: 163

    When 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.

    #40620

    WiggleChicken
    Participant
    Post count: 163

    Ha! 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!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.