WordPress.org

Forums

KIA Subtitle
[resolved] Display subtitle in feed? (10 posts)

  1. Atarian
    Member
    Posted 8 months ago #

    I'm using WordPress to host my podcast. I'm using your awesome subtitle plugin to display the episode number, because I don't want the number in the actual title. I would however like my feed to display the subtitle like so "SUBTITLE: POST TITLE". Is this possible?

    Thanks!

    https://wordpress.org/plugins/kia-subtitle/

  2. Atarian
    Member
    Posted 8 months ago #

    I figured it out myself. Just in case anyone else ever needs a similar functionality, edit includes/feed-rss2.php, and add

    <?php if( function_exists( 'the_subtitle' ) ) the_subtitle( '', ': ' ); ?>

    Where you want athe subtitle. Note, this also inserts a colon and a space after the subtitle.

    Thanks again for the plugin!

  3. helgatheviking
    Member
    Plugin Author

    Posted 8 months ago #

    No, please don't hack core files. That's a terrible idea and your edits will either be overwritten when you update WordPress or you'll be locked into your current version and will never update.

    The RSS feed title looks to be filterable. I can't test this write now, but this might be close to what you need.

    function kia_rss_subtitle( $title, $sep ){
    	if( function_exists( 'the_subtitle' ) ) {
    		$title = the_subtitle( '', ': ', false ) . $title;
    	}
    
    	return $title;
    }
    add_filter( 'wp_title_rss', 'kia_rss_subtitle' );
  4. Atarian
    Member
    Posted 8 months ago #

    Thank you! I should have mentioned I was using a plugin that let me have copies of the feed*.php files in my theme directory for modifying, but this lets me use one less plugin.

    I made one modification, the way you have it was appending the most recent subtitle to the title of the feed. Just need to change 'wp_title_rss' to 'the_title_rss'. This will place it before the item title, instead of after the feed title.

    Thanks again!

  5. helgatheviking
    Member
    Plugin Author

    Posted 8 months ago #

    Good catch. I don't know much about feeds, but it seemed like there should've been a filter there and there was!

  6. mscgl
    Member
    Posted 8 months ago #

    Where do you put this code ?

    function kia_rss_subtitle( $title, $sep ){
    if( function_exists( 'the_subtitle' ) ) {
    $title = the_subtitle( '', ': ', false ) . $title;
    }

    return $title;
    }
    add_filter( 'wp_title_rss', 'kia_rss_subtitle' );

  7. helgatheviking
    Member
    Plugin Author

    Posted 8 months ago #

    I used to say your theme's functions.php, but this isn't really theme-related. Therefore you should make it a site-specific snippet plugin.

  8. mscgl
    Member
    Posted 8 months ago #

    Thanks

    but I get this error when viewing the feed page : This page contains the following errors:

    error on line 55 at column 368: xmlParseEntityRef: no name
    Below is a rendering of the page up to the first error.

    Warning: Missing argument 2 for kia_rss_subtitle() in /home/content/m/s/c/mscgluk/html/pubuk/wp-content/plugins/siteplugin/plugin.php on line 11

    <?php
    /*
    Plugin Name: Site Plugin
    Description: MSCGLUK Specific Code
    */
    
    // JUST START ADDING YOUR CODE AFTER THIS COMMENT BLOCK
    // REMEMBER TO USE COMMENTS BEFORE EACH SNIPPET USING SLASHES LIKE WE DO HERE
    // SO YOU REMEMBER WHAT EACH BIT OF CODE DOES
    
    function kia_rss_subtitle( $title, $sep ){
    if( function_exists( 'the_subtitle' ) ) {
    $title = the_subtitle( '', ': ', false ) . $title;
    }
    
    return $title;
    }
    add_filter( 'the_title_rss', 'kia_rss_subtitle' );
    
    ?>

    No error when removing the code from the file

    Any suggestions what it might be ?

    Thanks in advance

  9. helgatheviking
    Member
    Plugin Author

    Posted 8 months ago #

    It means you are missing the second argument, $sep. I'd probably just remove that argument. As I mentioned above, the code is untested.

  10. mscgl
    Member
    Posted 7 months ago #

    thanks anyways :)

Reply

You must log in to post.

About this Plugin

  • KIA Subtitle
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.