• 0

Resolved Using URL in boxes and feature with Qtranslate

Question

Posted · Report post

Hi
I’m using PagelinePro theme for a page i'm building: www.americasblindspot.com .
it's a bilingual site, spanish and english, using the Qtranslate
plugin, that works great for titles and texts, but I don't know how to add code so that the the URLs I add in the boxes and features redirects to the appropriate language page.
Example: I switch my page to Spanish, and all the text is indeed translated correctly. But when I clik on a feature or box link, it redirects back to the English version of that page.
Can i included anything in the field “Feature Link URL: Adding a URL here will add a link to your feature slide-Enter Feature Link URL” so that it will send me to the Spanish version?
Thanks in advance

Share this post


Link to post
Share on other sites

34 answers to this question

  • 0

Posted · Report post

Add the following to platformbase/functions.php

[CODE]
function add_lang_features($metadata, $object_id, $meta_key, $single){
if ( function_exists( 'qtrans_getLanguage' ) && isset($meta_key) && 'feature-link-url' === $meta_key) {

return sprintf( '%s?lang=%s', $metadata, qtrans_getLanguage() );
}
return $metadata;
}
add_filter('get_post_metadata', 'add_lang_features', true, 4);
[/CODE]

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Ok. I did something wrong.
From the editor in appearance, I selected the platformbase theme to edit. I opened function.php and on the bottom i pasted what you sent. But nothing happened.
did i do something wrong?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

You probably dont have the platformbase theme activated. Also strongly advise against using the wp theme/plugin editor, its BAD, always edit files with FTP

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

thanks for the advice. I went through my ftp platformbase/functions.php and pasted what you sent, and still doesn't work.
any ideas?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

[quote][color=#282828][font=helvetica, arial, sans-serif]You probably dont have the platformbase theme activated[/font][/color][/quote]

Go to Appearance/themes and activate the child theme.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I appreciate your patience. I'm a bigger obviously. But in any case, I activated platformbase. It deactivated the pro, or at least it shows as needing reactivating, deactivated all my widgets and sidebars, and it's still not redirecting me to the correct language page.
everything that is deactivated with platformbase theme is reconfigured when i reactivate the platformpro.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well the code will only run when platformbase is activated, yes widgets and menus may need re-adding, they are stored on a theme by theme basis.

Its up to you if you want to use it, i tested the code, it works 100%

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

OK. I re-added all now that pagelinesbase is activated. page looks as before, minus a tweak here and there, but it's still not directing me to the right pages. i don't doubt the code is 100% funcional, but I don't know what i'm doing wrong:
i included the code in pagelinesbase/functions via FTP, I activated pagelinesbase theme is appearance, i double checked all of the above...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I'm looking into it.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

OK it was slightly more complicated ;)

revised code.

[CODE]
function add_lang_features($metadata, $object_id, $meta_key, $single){

if ( ! is_admin() && function_exists( 'qtrans_getLanguage' ) && isset($meta_key) && 'feature-link-url' === $meta_key) {
remove_filter( 'get_post_metadata', 'add_lang_features', 999, 4 );
$data = get_post_meta( $object_id, 'feature-link-url' );
$link = sprintf( '%s/?lang=%s', $data[0], qtrans_getLanguage() );
add_filter('get_post_metadata', 'add_lang_features', 999, 4);
return $link;
}
return $metadata;
}
add_filter('get_post_metadata', 'add_lang_features', 999, 4);
[/CODE]

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hmmmm. Still not working. I replaced with the new code in the pagelinesbase/functions, and I confirmed the code code was actually changed. But still nothing. should i be adding something in the actual box to write the URL in each box and feature?
Thanks for your patience and insistance

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well yea, each feature will need a link, the filter just adds ?lang=xx to the end of the url

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Sorry, i didn't explain myself. Of course all boxes and features have a link. But none of them have the ?lang=xx ending... the filter is not working...

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

I have it working here, can you screenshot the feature settings for the feature on the home page

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

OK. It's very small, so let me know if you can see all of it.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

and once of the boxes

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

[quote name='gcoppola7' timestamp='1349887095' post='131150']
OK. It's very small, so let me know if you can see all of it.
[/quote]
Its small alright, where is it? lol

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

so sorry....
http://imgur.com/BpXhG
and
http://imgur.com/XKDTP

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

What are you trying to do? have you uploaded the images somewhere? imgur.com is easy

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

so sorry....
http://imgur.com/BpXhG
and
http://imgur.com/XKDTP

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

OK so what is the link? I cant actually see it, the feature link that is.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

feature: http://www.americasblindspot.com/chavez-renews-oil-mandate/
same for the box of course

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

The script is adding an extra / into the url either remove it in the script, or remove it from the url in the feature.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Almost there.
I erased directly in the link and the feature is working perfectly. Thank you so much.
The boxes though still don't work, even after I took the extre / from the link like with the features.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

That filter ONLY works for the feature link.

Share this post


Link to post
Share on other sites
This topic is now closed to further replies.