WordPress.org

Support

Support » Plugins and Hacks » KIA Subtitle » [Resolved] Display subtitle in feed?

[Resolved] Display subtitle in feed?

  • 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/

Viewing 9 replies - 1 through 9 (of 9 total)
  • 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!

    Plugin Author helgatheviking

    @helgatheviking

    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' );

    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!

    Plugin Author helgatheviking

    @helgatheviking

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

    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’ );

    Plugin Author helgatheviking

    @helgatheviking

    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.

    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

    Plugin Author helgatheviking

    @helgatheviking

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

    thanks anyways 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Display subtitle in feed?’ is closed to new replies.
Skip to toolbar