I have created a wordpress page that will output product details of a specific product from amazon: wordpress/product?asin=123

I'm just using the product page as a template and it really contains nothing. I'm just adding a filter to the content to put some contents into it.

I'm also using the wordpress seo plugin from yoast to take care of SEO stuff but it seems to be getting in the way. I currently have this code:

function ecom_title_filter($title){

            if($title == 'Product Details Page'){
                $asin = $_GET['asin'];
                $titles = get_titles($asin);
                if(count($titles) == 1){
                    $title = $titles[0];
                    $index = 1;
                    $title = '';
                    $title_count = count($titles);
                    foreach($titles as $item_title){

                        if($title_count > $index){
                            $title .= $item_title . ', ';
                            $title .= $item_title;





    return $title;

Then I'm adding it into the the_title and wp_title:

add_filter('the_title', 'ecom_title_filter');
add_filter('wp_title', 'ecom_title_filter');

The problem is that the page still retains the old page title which is Product Details Page and not the title that I'm returning from the method above. The method returns what I expect it to return so the problem is not the method. Any ideas?

1 Answer 1


Either deactivate the filter from the SEO plugin for that page with remove_filter() or use a later priority argument like this:

add_filter( 'the_title', 'ecom_title_filter', PHP_INT_MAX );
add_filter( 'wp_title',  'ecom_title_filter', PHP_INT_MAX );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.