Hi I'm having problems with the the_title
filter here's the code that I have:
function zen_title_filter($title){
if(is_singular()){
if(!empty($_GET['asin'])){
if($title == 'Product Details Page' || $title == 'Compare Products Page'){
$title = zen_get_titles();
}
}
}
return $title;
}
add_filter('the_title', 'zen_title_filter');
As you can see this filter updates both the menu title for the product details page and compare products page. But the behavior that I'm expecting is that it should only update the title of the post itself but not the menu title which in this case is also the same as the post title. Any ideas?
UPDATE
I'm actually generating the page on the fly. Using a page as the template. So the post id is the id of the page. What I'm doing is adding filter to the content and completely replace the content of the page using the new content:
add_filter('the_content', function($content){
if(is_page('compare')){
$asin = esc_attr($_GET['asin']);
$data = get_data($asin);
$smarty->assign('item_data', $data);
$content = $smarty->fetch('file.tpl');
}
return $content;
});
in_the_loop()
: stackoverflow.com/questions/13456521/…