Some things work on localhost but not on the web server
-
I have been struggling with this for a while now and I really hope somebody can help me out.
I have two different issues:
1) I have set up some basic code in order to redirect the user after posting a comment. Because I am integrating wordpress into an existing site, I wanted the comments to redirect back to the website’s blog page, rather than wordpress’ one.
This is the code I am using, it is located at the end of wp-comments-post.php$redirect_to_comments = $_SERVER["HTTP_REFERER"] . '#comments'; $location = apply_filters('comment_post_redirect', $redirect_to_comments); //$location = apply_filters( 'comment_post_redirect', $location, $comment ); wp_safe_redirect( $location );
This code works fine locally, but when I upload the changes to my website, posting a comment will redirect it to the wordpress admin page.
What could be going wrong here?2) On my custom blog page, I want the most recent blog to be displayed if no post id is specified via GET.
I use this very simple code:if(isset($_GET['postid']) === false) { $post = get_post(get_posts('numberposts=1')[0]->ID); } else { $post = get_post($_GET['postid']); }
This issue confuses me the most, as it works perfectly on localhost but when I use this on the web server, the get_posts function appears to call die() at some point, as the rest of the website just doesn’t appear – when get_posts is not commented out, the page is killed at that point.
I hope someone can help me with these issues. Any ideas/suggestions are welcome as this has had me stumped for ages.
Thanks.
- The topic ‘Some things work on localhost but not on the web server’ is closed to new replies.