最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Change post title but not in widgetsmenuetc

programmeradmin0浏览0评论

I have searched and searched, and can't find what I'm doing wrong.

I am using a shortcode and custom field to edit the title of a post by adding an audio player right behind the title. At first I was using "is_single" and that was working, however it changes the title in widgets too.

So I tried to use "in_the_loop" in the code, but then nothing shows up, so I'm clearly doing something wrong. This may be because I'm piecing together multiple pieces of code I found to get this working.

add_filter( 'the_title', 'se385007_title_filter' , 20, 2  );
function se385007_title_filter( $title, $post_id ) 
{
    if ( in_the_loop()){

    $termp = get_post_meta($post_id, "term_pronunciation", true);
        if($termp != ""){ $title .= "  [sc_embed_player fileurl=\"" . $termp . "\"]"; }
        
    }
    return do_shortcode( $title ); 
    
}
发布评论

评论列表(0)

  1. 暂无评论