A
A
Aricus2019-06-14 15:19:35
RSS
Aricus, 2019-06-14 15:19:35

Wordpress: Why is the custom feed not working?

I add to functions.php in the theme:

add_action( 'init', function(){
  add_feed( 'smartprice', 'smartprice_markup' );
});
function smartprice_markup() {
  do_action( 'my_before_feed' );
  header( 'Content-Type: ' . feed_content_type( 'rss' ) . '; charset=' . get_option( 'blog_charset' ), true );
  status_header( 200 );
  echo '<?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/"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    <channel>
      <?php 
      
      ...

      ?>
    </channel>
  </rss>
  <?php
  exit;
}

When you try to add "/feed/smartprice" to the entry url, it gives a 404 error. If you add "/feed/feed", then it normally outputs xml according to a predefined template. If I write
smartprice_markup();
the xml I need, it is also written correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aricus, 2019-06-17
@Aricus

If anyone is interested, the feed works, but only if you add "?feed=smartprice" to the url. Why permalinks don't work, I don't know, but I don't need them, so I won't dig. Thanks Simon for the tip .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question