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条)