Page not visible in 'All pages' after being added through PHP

I'm adding some pages pragmatically as a subpage. This all works well on a test website in 1 locale. However, on the live website we have WPML with 2 locales. When adding them there, these pages DO NOT show up in the all pages list. Also accessing their url give a 404. However, when you access the edit mode directly: https://xxxxxxx.nl/wp-admin/post.php?post=3280&action=edit&lang=nl The page 'comes to life' (even without saving) and is visible as sub-page in the 'all pages' page. Any …
Category: Web

How to change the canonical link from a category or taxonomy archive?

On this url: https://www.phuket-luxury-villas.us.com/tourist-spots/buddhist-temples-wats/ I have a wrong canonical link: <link rel="canonical" href="https://www.phuket-luxury-villas.us.com/tourist-spots/buddhist-temples-wats/" /> It used to be the follow canonical link: <link rel="canonical" href="https://www.luxuryvillasphuketthailand.com/tourist-spots/buddhist-temples-wats/" /> I tried to use this code: function yoast_seo_canonical_change_woocom_shop( $canonical ) { if ( is_archive() ) { echo ''; } } add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_woocom_shop', 10, 1 ); But it seems that is put now too many canonical links on the website... Any idea what else I can do? This mentioned url, is an archive (done …
Category: Web

Bypass "supress_filters" in WP Query

Apparently, for some illogical reason, the developers decided that the only way to fetch posts in all languages, is to add supress_filters=true to the WP_Query (instead of having like say, a language_code=all option). Anyways, I am in a situation where I need to fetch posts in all languages, but ALSO modify the WP_Query using filters. Is there a way to enforce that my filters are being added to the query, even though supress_filters is set to false? This is the …
Category: Web

WPML language switcher for custom rewrite rules

I am making custom rewrite rules for categories in a dual-language project (german as main, english as second language). The urls look like this example.com/fliegen > shows archive.php for category fliegen example.com/en/aviation > shows archive.php for category aviation (the translated fliegen) This could be achieved by changing the category-base to . (although it doesn't seem to work in my case?) Unfortunately that wouldn't be enough for me, anyways; there is a custom taxonomy called filter in the game aswell, which …
Category: Web

Change WooCommerce currency programmatically on AJAX request

I am adding a custom ajax_action to fetch a product and display price html (same template as everywhere else on my page), the issue is that the price being returned is not equal to the current price set by user. In my AJAX call I have tried sending currency/wcmlc as a POST/GET parameter but this does not work. I have also tried different actions I could find online. I believe the problem is that the filter wcml_client_currency is not effective …
Category: Web

Line Breaks are stripped off when direction property is found

The line breaks are stripped off when the p tag has a dir attribute inserted, to explain further I'll list some examples. Let's say we have 2 lines of text as following <p>Text Paragraph Number One Goes Here</p> <p>Text Paragraph Number Two Goes Here</p> If I want to add line breaks between the two paragraphs it works fine to become like: <p>Text Paragraph Number One Goes Here</p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p>Text Paragraph Number Two Goes Here</p> However if …
Category: Web

How To Write An Inner Join With WP Query

I have a ACF relationship field for a custom post type, properties. Moreover, the content of these properties can either be in English or Spanish. When I use a ACF relationship field to associate properties to a user on the user edit page -- /wp/wp-admin/user-edit.php -- everything works as expected, and I can select from the relationship drop down the properties I want for this user. My question is this: how can I write a query inside this filter such …
Category: Web

Why template_include filter does not work with WPML plugin?

I have some issue with WPML. I use two different product page fro the phisical product and for the video lessons. Now I added one more language to the project ussin WPML plugin. And It's okay but my chunk of code I using for changed the template does not work. I use this code for changing template: add_filter( 'template_include', 'bsl_single_product_template_include', 50, 1 ); function bsl_single_product_template_include( $template ) { if ( is_singular('product') && (has_term( 'cosmetics', 'product_cat')) ) { $template = get_stylesheet_directory() …
Category: Web

Custom Post Type slug and WPML gets 404 error

i do have a curious problem on a new wordpress developpement. i have many CPT and WPML working on the site (default language is "french"). example, i have a custom post type who is : "marche" ( for Market in french ). i add a market in default language (french) inside of it (named "Gordes") i fill it with infos. Market is correct, and accessible here : -https://www.beprovence.be/marche/gordes.html url is ok, slug is ok, everything is ok. (default language). then …
Category: Web

Comments waiting but no comments found

So, I have a weird problem, and I'm not sure this is the right place to ask it, but I'm going to try because all other options have failed. I have a site that is running WPML and WooCommerce. On this site, I have a page called Guestbook, which is just like any other page, but it accepts comments. Anyways, I recently decided to do some clean-up of all the "awaiting comments". They're all spam so I hadn't bothered until …
Category: Web

Making WP theme / plugin multii-lingual without plugins

I am new to theme and plugin development and am stuck at the translation part. I read one place that if you are using __(), and e() throughout, you do not need a plugin like WPML. Is it correct? Is generation of the translation files (like .po files) for all the target languages a tough job to do? Will I have to manually copy paste stuff from google translator and paste it in these files? Please excuse my inexperience and …
Category: Web

WPML Translating a term/taxonomy programmatically

I have all terms in English and I am creating/duplicating the same ones for German language by using foreach on english terms and this way i create all terms for German language. The problem is when i need to assign an German term to its English version. I tried the trick with TRID like this: $trid = $sitepress->get_element_trid($englist_term_id, "taxonomy_name"); $sitepress->set_element_language_details($new_term_id, "taxonomy_name", $trid, $lang_code, $sitepress->get_default_language()); The problem is that $trid does not take any value (The first line of the above …
Category: Web

Localize custom form in wordpress / wpml

What I am trying to achive? I have a feedback form which is handled by a java servlet. This servlet expects a parameter "locale" for the currently selected language (see code below at xxx somehow put the current language there xxx). We want to migrate our current system to Wordpress / wpml. We will probably need to adjust our servlet. The example use case should go like this: open feedback form enter name/email/text submit The code of the feedback form …
Category: Web

Syncing WP Database Changes Between Environments: How To Handle Merging w/o touching database

I have a staging site which is originally a clone of the live site. On a staging site, I made some changes such as creating new pages, installing new plugins, adding new medias etc. Meanwhile the live version has been changed by a client as well. New pages are added, new plugins are added, new users, new orders, new subscribers... Now I want to know the best practice of how to push the staging site to live site in a …
Category: Web

WPML best page selector with php

I have a multilingual website made with WPML. I have php code to run across pages but I cannot uniquely target the page with is_page(ID) since the ID of the page changes across language domain. I need to write the code to target the page for each language. What is the best practice to target pages across language domain?
Category: Web

Mysql SELECT posts

how i can get posts via MYSQL from posts where language is 'en' and 'ru' I have this query $sql = "SELECT p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1 ON ( wm1.post_id = p1.ID AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' ) LEFT JOIN wp_postmeta wm2 ON ( wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL ) WHERE p1.post_status= 'publish' AND p1.post_type='post' ORDER BY p1.post_date DESC Limit 3"; I use WPML plugin.
Category: Web

Custom Enfold theme tab layout not compatible with WPML

I'm trying to create a new page with the Avia Layout Architect but there are some problems. I used the health check plugin to disable all plugins and tested if the tab works with my custom theme, which it does. However, as soon as I activate WPML, the tabs are broken. How they are broken is visible from the image attached. I have to state that I'm not sure if the tabs ever worked with WPML. I got the responsibility …
Category: Web

Structure of multilingual and multiregional directory listing website for translation

What is the best translation structure for a multilingual and multiregional directory website? Let's say our listing owners as members of our work team are from around 20 different countries with different languages and I want each of them to submit their listings in the official language of their country and all the listings are aggregated on our site which has the default English language. Our directory site, whose default language is English, will be translated into at least twenty …
Category: Web

About

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