How to implement Polylang functions in my theme's php file?

I am translating a site with Polylang that was created by someone else using a custom theme. Some strings couldn't be found by Polylang, so I need to manually register them for Polylang to see. Now, some of the strings were pretty easy to translate using __(): $args = shortcode_atts([ 'link' => 'service', 'text' => __('Get the code now!'), 'title' => __('Code'), 'id' => '', 'class' => 'width300', ], $args, '' ); But I don't know how to translate strings …
Category: Web

Polylang and template files

I divided the website i am making in diferent template files for example: Category for blog -> category-blog.php Category for projects -> category-projects.php But now I am using the POLYLANG plug in to make the translations. I've noticed that while i am creating the respective category in other languages the template does not apply for example category-blog.php file does not apply to the category-blog.php in other languages. Is any way that i can use the same category template file to …
Category: Web

How to display translated content with custom slug?

I used Polylang plugin to translate pages, So url of english page https://www.example.com/protfolio When I translated this page will be https://www.example.com/ar/protfolio-ar So I can't see content of the page because I addedd -ar in slug but polylang can't duplicate slug so How can I show translated content even I added custom slug
Category: Web

Translate website without duplicate custom post

I have a website where anyone can post jobs from frontend. The jobs pages are rendered by custom archive and single pages in my custom theme. I want the website to be multi language with switcher. The problem is to translate the static text in archive-job.php and singe-job.php, without translating the content of jobs. I tried polylang, but that one needs multiple posts, one for each language. Which means that I need to duplicate the post content Is there a …
Category: Web

custom theme: english .mo file not working

I'm having an issue with a .mo file. I have a fully functioning localized custom theme that's running in four languages for the moment: Dutch, English, French and Spanish. There is one problem: the English localization doesn't work. The other languages work just fine. The translation plugin is polylang. The plugin for creating .po and .mo files is CodeStyling Localization. The .po and .mo files are situated in the folder /language/ inside my theme. The theme is localized and works …
Category: Web

String translation for esc_html__() when registering string

I am trying to translate the string 'Home' in wordpress that is registered as an esc_html__(). This is the code registering the themes functions.php: if(!function_exists('gem_breadcrumbs')) { function gem_breadcrumbs($new = false) { $text['home'] = esc_html__('Home', 'thegem'); }} /* there many more strings in the function but I only need to translate 'Home' To register the string I am using polylang (but it could be anything not specific to polylang) and the documentation refers to registering a simple string _e() using the …
Category: Web

Multisite custom rewrite urls

On a multisite installation, which is running the Polylang plugin, I want to add a custom rewrite rule. Currently, my permalink structure is: http://host.com/sitename/language/pagename Now I want to add a querystring called country, as such: http://host.com/sitename/country/language/pagename I have tried the following, but to no avail: function custom_rewrite_basic() { add_rewrite_tag('%country%', '([^&]+)'); add_rewrite_rule('^([a-z]+)/?', 'index.php?country=$matches[1]', 'top'); } add_action('init', 'custom_rewrite_basic'); Any thoughts? -- EDIT Getting closer, but still not there: add_rewrite_tag('%country%', '([^&]+)'); add_rewrite_tag('%lang%', '([^&]+)'); add_rewrite_rule('^([^/]*)/([^/]*)/?','index.php?country=$matches[1]&lang=$matches[2]','top'); The problem here is that: polylang recognized the country …
Category: Web

What to write in the htaccess in order to detect browser language and point accordingly?

On short: I use Polylang plugin for my web but it's option to detect browser language won't work because I need to use cache in the whole site, including the homepage. I have a bilingual website (english and spanish) which handles lots of Custom Post Type and Custom Fields data. This means that I MUST use cache and CDN (like Cloudflare) in order to achieve good speed and performance by serving static files. This is not my field of expertise …
Category: Web

Polylang : Display term archive even if no posts

I use ACF to customize taxonomy term archives pages which are in fact Team member pages. Pages are translated with the help of Polylang. Problem is : If the member has no related posts, I can access directly the member page, but the translated page is not linked to the language switcher menu. Instead it has been replaced with a link to translated homepage. I found that this is common behaviour in Polylang. It is programmed to never show translated …
Category: Web

Custom post ui plugin & WP_Query - Polylang

I used to have a multilingual website translated with Qtranslate but now I am changing this to Polylang. I had a wp_query (below) that was working fine and when converted to polylang shows that no posts match my criteria <?php $args = array( 'post_type' => 'conversatietafel', 'posts_per_page' => 10, 'category_name' => 'Volwassene', 'public' => True, ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> Categories and …
Category: Web

Filter language in Polylang for custom taxonomy

I'm trying to filter custom taxonomy by language. To achieve this, I use WP_Query class with the following arguments: $args = array( 'post_type' => ['post', 'page'], 'post_status' => 'publish', 'lang' => $language, 'tax_query' => array( array( 'taxonomy' => $taxonomy_custom_category, 'field' => 'name', 'terms' => $taxonomy_term, ), ), ); Where $language is one of the language retrieved by pll_languages_list(). However, except for the language by default, the query results is always empty. Is there any way to build a form with …
Category: Web

How to get the webshop page in 2:nd language, with Polylang and Hyyan

I have moved content from one WP (server) to another. I use WooCommerce, Polylang and Hyyan WooCommerce Polylang Integration. I might have done something wrong in the setup. I have a shop page in Swedish, and it's marked as "webshop page" (in swedish it is 'butikssidan') in the listing of pages. It has version in English but - the english version is not marked "webshop page". How can I mark the other webshop page as "webshop page"? I looked in …
Category: Web

different domains disabled in polylang

Short: In Languages -> Settings -> URL modifications, the options "The language is set from the subdomain name in pretty permalinks" and "The language is set from different domains" are disabled. Why is this and how can I make these boxes selectable? I am particularly interested in the last option (different domains). Versions: Wordpress 5.5.1, Polylang 2.8.3 Background: My goal is a bilingual website (single web site install using polylang). I have two domains domain.aa and domain.bb for the languages …
Category: Web

Multilanguage website get the title, on different languages

I am working on a website, and I am using Polylang to translate it to a different language. In my code I want to get a page title, and display it. My issue is I cannot get it by ID or page_by_path because its going to display the English version of the page on every language. For example: I want to display the Contact page title on english Contact and on another language its equivalent translated contact page title. Is …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.