You are here:  » Changing Meta Title


Changing Meta Title

Submitted by Steve2507 on Thu, 2013-09-19 09:09 in

Hi,

I've finished installing (thank you David for all your help) and I'm slowly adding affiliate feeds to the system (can't believe how poor some of them are).

I want to change the meta title away from category:, merchant: etc.

Could anyone tell me how to do this?

Thanks

Steve

Submitted by support on Thu, 2013-09-19 10:15

Hello Steve,

The merchant:, category: and brand: prefixes derive from that fact that those pages are derived from the search module, the title is the query and the prefixes are the operators that generate the merchant / category and brand index search results e.g.

category:Category Name:

They can be removed easily, a popular modification to standalone Price Tapestry is simply to remove the operators and the ":" character. To do this in the plugin, if you edit the file pto.php and look for the following code at line 272:

  $title = htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"));

...and REPLACE with:

  $title_pto_q = str_replace(array(":","merchant","category","brand"),"",$pto_q);
  $title = htmlentities($title_pto_q,ENT_QUOTES,get_settings("blog_charset"));

Cheers,
David.
--
PriceTapestry.com

Submitted by Steve2507 on Thu, 2013-09-19 12:23

Hi David,

Thanks.

That works sort, but what I'm fully after is changing the word, so

"Category:" would be "Prices For "
"Merchant:" woud be "Check The Latest Prices At "
"Brand:" would be "Latest Prices Of "
"Product: would be "Latest Price Of "

Thanks

Steve

Submitted by Steve2507 on Thu, 2013-09-19 12:39

Hi David,

I managed to sort out the category, merchant and brand titles, it's just the product one left.

I entered:

 $title_pto_q = str_replace(array("category"),"Price Comparison For ",$pto_q);
 $title_pto_q = str_replace(array("merchant"),"Check The Latest Prices At ",$title_pto_q);
 $title_pto_q = str_replace(array("brand"),"The Latest Prices Og ",$title_pto_q);
 $title_pto_q = str_replace(array(":"),"",$title_pto_q);

Thanks

Steve

Submitted by support on Thu, 2013-09-19 12:48

Hi Steve,

Great! The product (and review) page meta title is actually under control of a template, so you can change this from wp-admin > Settings > PriceTapestry.org and scroll down to the Product / Title template; which defaults to:

%PRODUCT_NAME%%IF_REVIEW% Reviews%ENDIF_REVIEW%

...so you could REPLACE with:

The latest price of %PRODUCT_NAME%%IF_REVIEW% with customer reviews%ENDIF_REVIEW%

So for "Blue Widget", the product page title would be:

The Latest Price Of Blue Widget

...and for review pages:

The Latest Price Of Blue Widget with customer reviews

The same template is used for both product and review page titles but if you require finer control, just let me know your preferred titles for each and I'll describe the changes (it will be easy to add support for IF/ELSE if required)

Cheers,
David.
--
PriceTapestry.com

Submitted by Steve2507 on Thu, 2013-09-19 13:15

Hi David,

That's brilliant, works perfect.

Thanks for the help.

Steve

Submitted by firstbye on Fri, 2019-09-13 03:15

Hi David,

Keen to utilize the IF/ELSE feature. How do we go about integrating that to the code?

Cheers
Fb

Submitted by support on Fri, 2019-09-13 07:36

Hi Fb,

Sure - can you describe which text / page you want to change conditionally (based on what condition) and I'll point you in the right direction...

Cheers,
David.
--
PriceTapestry.com

Submitted by firstbye on Fri, 2019-09-13 16:37

Hi David,
I'd to use the IF/ELSE condition for the additional %DB_fields% to display optional content on the product page.

i.e:

%IFDB_fields%
Yes content
%ELSEIFDB_fields%
No content
%ENDIFDB_fields%

Cheers
Fb

Submitted by support on Mon, 2019-09-16 09:35

Hi,

To add support for:

%IFDB_field%
Yes content using %DB_field%
%ELSEIFDB_field%
No content
%ENDIFDB_field%

...edit pto_product.php and look for the following code at line 524:

        $html_product = str_replace("%DB_".$field."%",$product->$field,$html_product);

...and REPLACE with:

        if ($product->$field)
        {
          $html_product = str_replace("%IFDB_".$field."%","",$html_product);
          $html_product = preg_replace('/%ELSEDB_".$field."%(.*)%ENDIFDB_".$field."%/','',$html_product);
          $html_product = str_replace("%DB_",$product->$field."%",$html_product);
        }
        else
        {
          $html_product = preg_replace('/%IFDB_".$field."%(.*)%ELSEDB_".$field."%/','',$html_product);
          $html_product = str_replace("%ENDIFDB_".$field."%","",$html_product);
        }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by firstbye on Thu, 2019-09-19 11:15

Thanks David,
The data from the %DB_field% are working but the

%IFDB_field%
%ELSEIFDB_field%
%ENDIFDB_field%

just appear as text.

I'm also currently using code from https://www.pricetapestry.org/node/420
which gives me the breadcrumb links that appear below main product name header.

when I add the above code from node 374, the

%IFDB_field%
%ELSEIFDB_field%
%ENDIFDB_field%
%DB_field%

all appear as text and breadcrumbs no longer function.
Which line of code from node 374 can I merge into 420 code?

regards
Fb

Submitted by support on Fri, 2019-09-20 09:23

Hello Fb,

I'd used the wrong variable name for the value replacement in the above modification - please could you check with the above, and if still not working or with regards to how to merge with the code from node 420 please could you post the section of code you're modifying and I'll check it out further with you...

Thanks,
David.
--
PriceTapestry.com

Submitted by firstbye on Wed, 2019-10-02 11:56

Prefect! Thanks David.

Submitted by firstbye on Wed, 2019-10-02 12:34

Hmm me again... spoke to soon :/

What initially happened was that the placement tags disappeared and the page looked fine when i updated the code.

I initiate thought I had added the %ELSEIFDB_field% to the page but when i was tested the %ELSEIFDB_field% conditions, I'd still get the placement tag as text %ELSEIFDB_field% and display that conditional results.

i.e green tick for crypto payment and red cross for no crypto payment

Which part of the code would you like me to send to you?

regards
Fb

Submitted by support on Wed, 2019-10-02 14:02

Hi,

If you could email me your modified pto_product.php and also as a text file the contents of the Product / Main template (from wp-admin > Settings > PriceTapestry.org) I'll check it out further with you...

Thanks,
David.
--
PriceTapestry.com