woocommerce offtopic - How can I change field values of posts before displaying

I have wordpress project with woocommerce. What I'm trying to achieve is to change values before displaying them on

I have wordpress project with woocommerce. What I'm trying to achieve is to change values before displaying them on the view page.

For example depending on session/cookie I want to change the language of post title and content

Using the hooks the_title, the_content I was able to achieve it. The problem is when I try to do the same for the_excerpt hook, it's just never called.

Relevant code from functions.php :

add_filter('the_title', 'custom_lang_title');

function custom_lang_title($title){
    if($otherlang){
        return get_field('lang_title');
    }else{
        return $title;
    }
}

add_filter('the_content', 'custom_lang_desc');

function custom_lang_desc($content){
    if($otherlang){
        return get_field('lang_content');
    }else{
        return $content;
    }
}


//The code below does not work

add_filter('the_excerpt', 'custom_lang_excerpt');

function custom_lang_excerpt($desc){
    if($otherlang){
        return get_field('lang_excerpt');
    }else{
        return $desc;
    }
}

I'm completely new to wordpress, so if don't really know what other info can be helpful. I can provide more info on request.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744835120a4596215.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信