Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing issues viewing some pages in both the default language and other languages after updating WPML. They have identified that removing custom code from the functions.php file in their Flatsome child theme resolves the issue, but re-adding it brings the problem back.
Solution:
We recommend reviewing the custom code in the functions.php file to identify any potential conflicts or errors that could be causing the issue with WPML. Since the WPML support team does not provide support for custom code, we advise the client to consult with their developer or the person who added the custom code. This approach will help pinpoint and resolve the specific code causing the problem.

Please note that this solution might be outdated or not applicable to your specific case. If the issue persists, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you need further assistance, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 3 replies, has 0 voices.

Last updated by Dražen 2 weeks, 3 days ago.

Assisted by: Dražen.

Author Posts
September 24, 2025 at 11:44 am #17428965

Omer-farukO

Background of the issue:
I've been using WPML with Flatsome for years. I recently updated WPML. I now need to restore my site to a previous date.

Symptoms:
I can't view some pages in both the default language and other languages after the WPML update.

Questions:
How can I restore my site to a previous date?

September 24, 2025 at 12:15 pm #17429138

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

here is a ticket, please check further and let me know once you have found the plugin that is causing the issue.

I will advise further, and if something that we can help with.

Let me know how it goes.

Regards,
Drazen

September 24, 2025 at 10:50 pm #17430287

Omer-farukO

I've done a detailed review. All my plugins are active. I'm using the Flatsome child theme, and there's some code in my functions.php file. When I completely delete it, the problem goes away. However, when I add it, the problem persists. I'm sharing the file with you in the attachment. Can you tell me which code might be the problem? Any ideas?

--------------------------------------------------------------------------------------------
<?php
// hata durumunda sepete ekle butonunun sürekli dönmemesi için
<script>
jQuery(document).ready(function($) {
$('.pewc-has-extra-fields form.cart .single_add_to_cart_button').click(function(e) {
setTimeout(function() {
$('.pewc-has-extra-fields form.cart .single_add_to_cart_button').removeClass("loading");
}, 1000);
});
});
</script>
} );

/** Sepetetinizde ürün bulunmuyor uyarısını kaptmak için */
add_action( 'wp_footer', function() {
<script>
jQuery(document).ready(function($) {
$('.single-product .header-nav-main li.cart-item.has-dropdown').removeClass("current-dropdown");
});
</script>
} );

/** recaptcayı sadece iletişim sayfasına yüklemek için */
function block_recaptcha_badge() {
if ( !is_page( array( 'contact', 'iletisim' ) ) ) {
wp_dequeue_script( 'google-recaptcha' );
wp_deregister_script( 'google-recaptcha' );
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
}
}
add_action( 'wp_print_scripts', 'block_recaptcha_badge' );

/*Plugin Name: Preserve Page and Taxonomy Hierarchy on Edit Menus Screen*/
class Preserve_Page_and_Taxonomy_Hierarchy {

function __construct() {
add_action( 'load-nav-menus.php', array( $this, 'init' ) );
}

function init() {
add_action( 'pre_get_posts', array( $this, 'disable_paging_for_hierarchical_post_types' ) );
add_filter( 'get_terms_args', array( $this, 'remove_limit_for_hierarchical_taxonomies' ), 10, 2 );
add_filter( 'get_terms_fields', array( $this, 'remove_page_links_for_hierarchical_taxonomies' ), 10, 3 );
}

function disable_paging_for_hierarchical_post_types( $query ) {
if ( ! is_admin() || 'nav-menus' !== get_current_screen()->id ) {
return;
}

if ( ! is_post_type_hierarchical( $query->get( 'post_type' ) ) ) {
return;
}

if ( 50 == $query->get( 'posts_per_page' ) ) {
$query->set( 'nopaging', true );
}
}

function remove_limit_for_hierarchical_taxonomies( $args, $taxonomies ) {
if ( ! is_admin() || 'nav-menus' !== get_current_screen()->id ) {
return $args;
}

if ( ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ) {
return $args;
}

if ( 50 == $args['number'] ) {
$args['number'] = '';
}

return $args;
}

function remove_page_links_for_hierarchical_taxonomies( $selects, $args, $taxonomies ) {
if ( ! is_admin() || 'nav-menus' !== get_current_screen()->id ) {
return $selects;
}

if ( ! is_taxonomy_hierarchical( reset( $taxonomies ) ) ) {
return $selects;
}

if ( 'count' === $args['fields'] ) {
$selects = array( '1' );
}

return $selects;
}

}

new Preserve_Page_and_Taxonomy_Hierarchy;

// SKU ARAMA İÇİN KOD - Function to modify the search query to include SKU in WooCommerce product searches -
function search_by_sku_in_woocommerce( $search, $wp_query ) {
global $wpdb;

// Check if it's a search query and WooCommerce is active
if ( ! $wp_query->is_search() || ! $wp_query->is_main_query() || ! is_search() || ! class_exists( 'WooCommerce' ) ) {
return $search;
}

// Get the search query
$search_term = $wp_query->query_vars['s'];

// Only modify the search if there is a search term
if ( ! empty( $search_term ) ) {
// Get the current search query parts
$search = " AND ({$wpdb->posts}.post_title LIKE '%" . esc_sql( $search_term ) . "%'
OR {$wpdb->posts}.post_content LIKE '%" . esc_sql( $search_term ) . "%'
OR EXISTS (
SELECT 1 FROM {$wpdb->postmeta}
WHERE {$wpdb->postmeta}.meta_key = '_sku'
AND {$wpdb->postmeta}.meta_value LIKE '%" . esc_sql( $search_term ) . "%'
AND {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
))";
}

return $search;
}
// Hook the function into the 'posts_search' filter
add_filter( 'posts_search', 'search_by_sku_in_woocommerce', 10, 2 );

// admin urunler sayfasında kategoriye göre filtreleme kısmını statik olarak gösterir
add_filter( 'woocommerce_product_category_filter_threshold', 'dcwd_categories_dropdown' );
function dcwd_categories_dropdown( $dropdown_cutoff ) {
return PHP_INT_MAX; // Ensure that the threshold is never reached.
}

//upsell kısmında sadece belirli bir niteliği göstermek için kullanılan kod
function modify_woocommerce_upsell_display_based_on_attribute( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' ){

remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );

global $product;

if ( ! $product ) {
return;
}

// Handle the legacy filter which controlled posts per page etc.
$args = apply_filters(
'woocommerce_upsell_display_args',
array(
'posts_per_page' => $limit,
'orderby' => $orderby,
'order' => $order,
'columns' => $columns,
)
);

wc_set_loop_prop( 'name', 'up-sells' );
wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_upsells_columns', isset( $args['columns'] ) ? $args['columns'] : $columns ) );

$orderby = apply_filters( 'woocommerce_upsells_orderby', isset( $args['orderby'] ) ? $args['orderby'] : $orderby );
$order = apply_filters( 'woocommerce_upsells_order', isset( $args['order'] ) ? $args['order'] : $order );
$limit = apply_filters( 'woocommerce_upsells_total', isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : $limit );

// set your custom taxonomy here.
$taxonomy = 'pa_seri-adi';

$term_slugs = wp_get_post_terms( $product->get_id(), $taxonomy, ['fields' => 'slugs'] );

$posts_ids = get_posts( array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'posts_per_page' => 60,
'post__not_in' => array( $product->get_id() ),
'tax_query' => array( array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term_slugs,
) ),
'fields' => 'ids',
'orderby' => 'rand',
) );

if( !empty( $posts_ids ) ){

// Get visible upsells then sort them at random, then limit result set.
$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $posts_ids ), 'wc_products_array_filter_visible' ), $orderby, $order );
$upsells = $limit > 0 ? array_slice( $upsells, 0, $limit ) : $upsells;

wc_get_template(
'single-product/up-sells.php',
array(
'upsells' => $upsells,

// Not used now, but used in the previous version of up-sells.php.
'posts_per_page' => $limit,
'orderby' => $orderby,
'columns' => $columns,
)
);
}

}
//'woocommerce_share' kancasını 'woocommerce_after_single_product_summary' ile değiştirerek pozisyonu değiştirebiliriz. yada farklı bir kanca pozisyonu ile
add_action( 'woocommerce_share', 'modify_woocommerce_upsell_display_based_on_attribute', 15 );

// megamenüde altkategorileri otomatik eklemek için kod
function _custom_nav_menu_item( $title, $url, $order, $parent = 0 ){
$item = new stdClass();
$item->ID = 10000000 + $order + $parent;
$item->db_id = $item->ID;
$item->title = $title;
$item->url = $url;
$item->menu_order = $order;
$item->menu_item_parent = $parent;
$item->type = '';
$item->object = '';
$item->object_id = '';
$item->classes = array();
$item->target = '';
$item->attr_title = '';
$item->description = '';
$item->xfn = '';
$item->status = '';
return $item;
}
add_filter("wp_get_nav_menu_items", function ($items, $menu, $args) {
if( $menu->term_id != 14946 ) return $items; // Where 24 is Menu ID, so the code won't affect other menus.

// don't add child categories in administration of menus
if (is_admin()) {
return $items;
}
$ctr = ($items[sizeof($items)-1]->ID)+1;
foreach ($items as $index => $i)
{
if ("product_cat" !== $i->object) {
continue;
}
$menu_parent = $i->ID;
$terms = get_terms( array('taxonomy' => 'product_cat', 'parent' => $i->object_id ) );
foreach ($terms as $term) {
$new_item = _custom_nav_menu_item( $term->name, get_term_link($term), $ctr, $menu_parent );
$items[] = $new_item;
$new_id = $new_item->ID;
$ctr++;
$terms_child = get_terms( array('taxonomy' => 'product_cat', 'parent' => $term->term_id ) );
if(!empty($terms_child))
{
foreach ($terms_child as $term_child)
{
$new_child = _custom_nav_menu_item( $term_child->name, get_term_link($term_child), $ctr, $new_id );
$items[] = $new_child;
$ctr++;
}
}
}
}

return $items;
}, 10, 3);

/**
* Ürün sayfasında resmin üstüne dinamik bir başlık ekler.
*/
add_action( 'woocommerce_before_single_product_summary', 'add_dynamic_heading_above_image', 5 );

function add_dynamic_heading_above_image() {
global $product;

// Ürünün "pa_seri-adi" niteliğini alıyoruz.
$terms = wp_get_post_terms( $product->get_id(), 'pa_seri-adi' );

// Eğer bir nitelik bulunursa ve bir hata yoksa, devam ediyoruz.
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
$term = $terms[0];
$link = get_term_link( $term );

// Başlık metni olarak seri adını ve ek metni birleştiriyoruz.
$heading_text = $term->name . ' Serisinin Tüm Ürünlerini Gör';

// HTML çıktısını ekrana basıyoruz.
echo '<div class="product-series-heading" style="text-align: center; margin-bottom: 20px;">';
echo '<h3 style="font-weight: bold; font-size: 18px;">';
echo '' . esc_html( $heading_text ) . '';
echo '</h3>';
echo '</div>';
}
}

September 25, 2025 at 5:33 am #17430537

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

I am afraid I can not help or advise on custom code, it is out of scope of our support.

I advise checking with your developer who added this code or similar.

Regards,
Drazen