RSS feed problem WordPress 4.7
-
Hello everybody, is there a problem with RSS feed of WordPress 4.7? … or I recently created a child theme and added somethings to functions.php maybe I did something wrong. It’s not working anymore.
-
This topic was modified 9 years, 4 months ago by
blu377.
-
This topic was modified 9 years, 4 months ago by
-
In what way is yoursite.com/feed/ not working?
Normally when I type example.com/feed/ Firefox opens Live Bookmarks automatically, now it wants to download a file says, you have chosen to open which is application/rss+xml…
I guess I did something wrong in the functions.php
Please provide a link to a page on your site where we can see this. Thanks.
Did you do anything feed related in your child theme?
Can I not share the website? This is my child theme’s functions.php
I tried to show 10 posts a page for one category by this code:
<?php function my_theme_enqueue_styles() { $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); ?> <?php // Opening PHP tag - nothing should be before this, not even whitespace add_action('pre_get_posts', 'diff_post_count_per_cat'); function diff_post_count_per_cat() { if (is_admin()) return; $cat = get_query_var('category_name'); switch ($cat) { case 'news': set_query_var('posts_per_page', 10); break; } } ?>Please provide a link to your site.
Sorry, I do not want to share it here. Thanks.
I checked with Google Chrome, on a newly installed wordpress feed starts like this:
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"...My site’s feed:
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"...Extra empty/blank 2 lines, other that everything same.
I guess that’s the issue?
1. remove the final ?> from your functions.php file.
2. your switch statement is incorrect. It does not have a default case.
3. Get rid of the ?> followed by the next line that starts with <?php
4. for the time being, comment out the add_action that changes the post count. If that fixes it, then fix that function so it’s good PHP.
Thanks a lot. I found these on the internet, I don’t know anything about these codes or PHP but I will try.
Just an update, I deleted PHP closing tags ?> and changed the code for showing 10 posts for a single category. Now RSS works. Thanks.
This is how my functions.php looks now, it might help someone, and if still something wrong please tell me.
<?php function my_theme_enqueue_styles() { $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); add_filter('pre_get_posts', 'posts_in_category'); function posts_in_category($query){ if ($query->is_category) { if (is_category('news')) { $query->set('posts_per_archive_page', 10); } } }I changed it to not resolved, I guess when I select resolved and I type a reply it won’t go up.
The topic ‘RSS feed problem WordPress 4.7’ is closed to new replies.