Link to home
Create AccountLog in
Avatar of Heather Ritchey
Heather RitcheyFlag for United States of America

asked on

Wordpress feed giving 500 error

Does anyone have ideas on why a feed would be giving a 500 error all of the sudden?

It worked fine up until a month ago. This is the function I'm using to call a custom feed template:

remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'item_feed_rss2', 10, 1 ); function item_feed_rss2() { $rss_template = get_template_directory() . 'parts/rss/feed-compliance.php'; if( get_query_var( 'post_type' ) == 'compliance_entry' ) load_template( $rss_template ); else do_feed_rss2(); // Call default function }

Open in new window

This is one of the urls that stopped working:

https://www.liftburden.com/feed?post_type=compliance_entry&src=mc&level=compliance-news


The site uses a custom taxonomy for these and is using the restrict content pro plugin. I have that plugin set to not block anything with the compliance_entry post_type for feeds.


Avatar of Scott Fell
Scott Fell
Flag of United States of America image

First, I would look at my php logs or other area where you get get a detail of the error other than a 500 error which does not really tell you anything.


On my Windows server with Plesk, sometimes the permissions get reset after an update and it is usually Plesk's fault and simply updating permissions solves issues.  But checking your php log to get the error detail will be the trick to getting the real issue.

Question is the URL you supplied (https://www.liftburden.com/feed?post_type=compliance_entry&src=mc&level=compliance-news) - is this a URL you control or is this on a remote site that you are pulling the feed from?


If I open that URL it returns this

<error>
<code>internal_server_error</code> <title>WordPress &amp;rsaquo; Error</title> <message> &lt;p&gt;There has been a critical error on this website.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://wordpress.org/documentation/article/faq-troubleshooting/&amp;quot;&gt;Learn more about troubleshooting WordPress.&lt;/a&gt;&lt;/p&gt; </message> <data> <status>500</status> </data> </error>

Open in new window

Just trying to establish where the 500 error is occurring and whether you have control over the code that is calling it?

Avatar of Heather Ritchey

ASKER

I control that url.


Just for extra info - that url is what we use in mailchimp so that the monthly mailing pulls the recent posts feed for the intended membership subscribed to.

With reference to Scott's post above - do you have access to the PHP error logs on the server that is creating the feed?

Sorry for the delay. The logs weren't working on the server. The error it shows is:


PHP Fatal error:  Uncaught Error: Failed opening required '/nas/content/live/consortium1stg/wp-content/themes/cccommparts/rss/feed-compliance.php' (include_path='.:/usr/share/pear/php:/usr/share/php') in /nas/content/live/consortium1stg/wp-includes/template.php:785#012Stack trace:#012#0 /nas/content/live/consortium1stg/wp-content/themes/child/functions.php(311): load_template('/nas/content/li...')#012#1 /nas/content/live/consortium1stg/wp-includes/class-wp-hook.php(312): item_feed_rss2(false)#012#2 /nas/content/live/consortium1stg/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array)#012#3 /nas/content/live/consortium1stg/wp-includes/plugin.php(517): WP_Hook->do_action(Array)#012#4 /nas/content/live/consortium1stg/wp-includes/functions.php(1631): do_action('do_feed_rss2', false, 'rss2')#012#5 /nas/content/live/consortium1stg/wp-includes/template-loader.php(48): do_feed()#012#6 /nas/content/live/consortium1stg/wp-blog-header.php(19): require_once('/nas/content/li...')#012#7 /nas/content/live/consortium1stg/index.php(17): require('/nas/content/li...')#012#8 {main}#012  thrown in /nas/content/live/consortium1stg/wp-includes/template.php on line 785

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer

I don't know how I missed that. It should be child instead of cccommparts.

So it should be this: 

/nas/content/live/consortium1stg/wp-content/themes/child/parts/rss/feed-compliance.php 


The code is using

$rss_template = get_template_directory() . 'parts/rss/feed-compliance.php';

Open in new window

So I don't know why it's using the wrong path.

Maybe echo out $rss_template to see what is happening.


I am pretty sure you need to use a slash in your concatenation. 


$rss_template = get_template_directory() . '/parts/rss/feed-compliance.php'; 

Open in new window


But you also want to make sure it is in the correct path. When I tried this on my own server, it provided the path of the theme, not the child theme if that matters.