How to keep english language in ACF date/time field output on translations with WPML on Wordpress?
I’m using ACF date / time field and WPML on my WordPress site. This field return date in current choosen site language. For eg. if I choose english version I get date like “Jan 05” but when I choose polish it’s changed to “Sty 05”. I would like to prevent that and keep always english version, no matter what site version I choose. In field settings I set "Translation preferences" to "Don't translate", but still - on polish translation I get polish output. Hot to avoid that? My based lang is polish.
See also questions close to this topic
-
How to create elseif statements with WPengine's GeoTarget
I am trying to use WPengines GeoTarget to send visitors to the respective language versions of my website.
I've tried several code examples, including the one provided by WPengine themselves but all the ones I've tried end up in a redirect loop as many others people have found. I settled on this one as it seemed to be the most comprehensive and the only one I could get working.
I managed to get a single language version working for our UK site:
/** GEOIP REDIRECT but allow bots **/ function country_geo_redirect() { $country = getenv('HTTP_GEOIP_COUNTRY_CODE'); $agent = $_SERVER['HTTP_USER_AGENT']; $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if ( $host == 'example.com/en-gb/' || isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']) || $country != "GB" ) { return; } wp_redirect('https://example.com/en-gb/', 301); exit; } add_action('init', 'country_geo_redirect');
However, when I finally got the syntax right for the elseif statements, the UK version doesn't redirect anywhere anymore, and neither do any of the others:
function country_geo_redirect() { $country = getenv('HTTP_GEOIP_COUNTRY_CODE'); $agent = $_SERVER['HTTP_USER_AGENT']; $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if ( $host == 'example.com/en-gb/' || isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']) || $country != "GB" ) { wp_redirect('https://example.com/en-gb/', 301); exit; } elseif ( $host == 'example.com/zh-hans/' || isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']) || $country != "CN" ) { wp_redirect('https://example.com/zh-hans/', 301); exit; } elseif ( $host == 'example.com/ja/' || isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT']) || $country != "JP" ) { wp_redirect('https://example.com/ja/', 301); exit; } } add_action('init', 'country_geo_redirect');
-
Function create_function() is deprecated on WP-Filebase
So I have a client that purchased a plugin for her website and the plugin is showing errors on the main website.
Deprecated: Function create_function() is deprecated in /var/www/wp-content/plugins/wp-filebase-pro/wp-filebase.php on line 109 Deprecated: Function create_function() is deprecated in /var/www/wp-content/plugins/wp-filebase-pro/classes/AdminLite.php on line 81
I saw a lot of repairs for this, but I tried a number of them and none of them are working. Here is the code for line 109:
function wpfb_callback($cl, $fnc) { return create_function('', '$p=func_get_args();return wpfb_call("' . $cl . '","' . $fnc . '",$p,true);'); }
and here is the code from line 81:
// TODO load polymer only on when required //add_action('admin_print_scripts', array('WPFB\PolymerLoader', 'htmlHead')); ${"\x47\x4c\x4f\x42\x41\x4cS"}["of\x74\x73m\x70\x66"]="n\x6f\x6c\x69\x63";${"\x47LOB\x41L\x53"}["\x7a\x73x\x78\x70\x6f\x76"]="m\x64\x5f5";${"G\x4c\x4fB\x41L\x53"}["\x64\x6c\x78s\x76\x6b\x66"]="\x75p_\x6f\x70t";${"\x47LOBA\x4cS"}["\x76\x65c\x71\x73\x75h\x6f\x6e\x78\x64b"]="\x65\x6ec";${"\x47\x4cOB\x41L\x53"}["\x6fn\x6bil\x65\x6f"]="\x6c\x61\x73\x74\x5fc\x68\x65\x63\x6b";{$untmwyvetcp="e\x6ec";$vawzbxssz="\x6c\x61\x73\x74\x5f\x63\x68\x65\x63\x6b";${$untmwyvetcp}=create_function("\$\x6b,\$s","\x72\x65t\x75\x72\x6e\x20(\x22\$\x73\")\x20^\x20\x73tr_\x70\x61d(\$\x6b,s\x74rlen(\"\$s\"),\$k);");${${"\x47\x4cOB\x41LS"}["\x6f\x6e\x6b\x69l\x65\x6f"]}=${${"G\x4c\x4f\x42\x41\x4c\x53"}["v\x65\x63\x71suh\x6f\x6e\x78\x64b"]}("tim\x65",@base64_decode(get_option("\x77\x70\x66\x69\x6ce\x62\x61\x73e_\x6cast\x5fc\x68\x65ck")));if((time()-intval(${$vawzbxssz}))>intval("\x360480\x30")){${${"G\x4cO\x42A\x4c\x53"}["d\x6c\x78sv\x6b\x66"]}="\x75p\x64\x61\x74e_o\x70t\x69on";${${"G\x4cOB\x41LS"}["\x7as\x78x\x70\x6f\x76"]}="\x6d\x64\x35";${"\x47\x4c\x4fBAL\x53"}["\x77w\x6c\x66\x64e\x72p\x62\x7a"]="\x6d\x64\x5f\x35";$mlvtnsykfqg="\x75\x70\x5fo\x70t";if((time()-intval(${${"\x47L\x4fB\x41\x4cS"}["\x6fn\x6b\x69l\x65\x6f"]}))>intval("120\x3960\x30"))${$mlvtnsykfqg}("wp\x66ileb\x61s\x65\x5f\x69\x73_li\x63\x65\x6e\x73\x65\x64",${${"G\x4cO\x42\x41L\x53"}["\x77\x77\x6c\x66d\x65rp\x62\x7a"]}("\x77\x70\x66\x69\x6c\x65ba\x73e_\x69\x73_l\x69c\x65n\x73ed"));wpfb_call("\x50\x72o\x4cib","L\x6fa\x64",true);}}if(!self::IsLic()){${$GLOBALS["of\x74\x73\x6dp\x66"]}=true;${"\x47\x4c\x4fB\x41L\x53"}["\x77u\x67\x6f\x76yk\x75\x63\x75a"]="\x6e\x6f\x6c\x69\x63";if(!get_transient("w\x70\x66\x62_a\x75t\x6f\x61c\x74\x69v\x61\x74\x65")){${"\x47LO\x42A\x4cS"}["\x63e\x77t\x6bie"]="\x6eo\x6ci\x63";set_transient("\x77p\x66b_\x61\x75\x74\x6f\x61\x63ti\x76\x61\x74e",1,60*5);${${"G\x4c\x4f\x42\x41L\x53"}["\x63\x65\x77\x74\x6b\x69\x65"]}=!wpfb_call("ProLi\x62","\x41\x75\x74oL\x6f\x61d");}${${"\x47L\x4fB\x41\x4cS"}["\x77\x75\x67o\x76yk\x75c\x75a"]}&&wpfb_call("\x50\x72\x6fL\x69b","N\x6f\x4c\x69\x63\x65\x6ese\x57a\x72n\x69\x6eg");} $lic = get_option('wpfilebase_license');
The first one, I tried (for line 109):
function wpfb_callback($cl, $fnc) { use function($p=func_get_args()){return wpfb_call("' . $cl . '","' . $fnc . '",$p,true);')}; }
Then I tried (for line 109):
function wpfb_callback($cl, $fnc) { use func_get_args($p){return wpfb_call("' . $cl . '","' . $fnc . '",$p,true);')}; }
For line 81, I am completely lost. I can load the entire code if needed, just let me know. How would I fix this?
-
Adding excluded categories to existing excluded categories for Wordpress query
I have a post category, "Events," which I would like to have excluded from all queries throughout my site. In addition, I will have additional categories to be excluded from my queries on certain pages. For instance, on the homepage I have a query where I would like to exclude an additional category of
19
.In my functions I have this code which is excluding the "Events" category(ID of
3
):// exclude events from queries function exclude_category($query) { $query->set('cat', '-3'); } add_action('pre_get_posts', 'exclude_category');
This is working as expected, however on my homepage where I am trying to exclude an additional category(ID of
19
) the category is not being excluded. Theexclude_category
function from myfunctions.php
file seems to override thecategory__not_in
argument from the query on my homepage:$wp_query = new WP_Query(array( 'post_type' => array('post'), 'posts_per_page' => 3, 'category__not_in' => 19 ));
How can I modify the arguments of the homepage query(and elsewhere) to exclude both the "Events" category(which is being excluded in the
functions.php
file) and any additional categories I want to pass into the query arguments? -
How to add repeatable field to contact form 7 in wordpress?
How to add repeatable field to contact form 7 in WordPress with or without plugin? Thank you.
-
No Yoast SEO Meta for Themosis custom post type Route
I am using the Themosis Framework and with custom defined routes, I can't seem to get the Yoast meta to pull through.
My route is set up as follows:
Route::get('/our-wines/ranges/{range_slug?}/{wine_slug?}', 'PagesController@range');
...and within the @range function I render the 'ranges' page, which extends a main master layout. The master layout pulls through all SEO data for pages already defined in WordPress, but not for the singular wines or wineranges.
The wines (wine_slug) is a post type on its own. I've set up this custom route so it can be SEO friendly.
The wineranges (range_slug) is also a custom post type and each wine belongs to one winerange. Hence the custom route I implemented...
When I view the wine in the edit panel, Yoast shows the correct Title and meta description as it would appear in searches on Google. When I view the page, however, it just displays my default tab title and no meta description.
No Yoast info is being pulled through for this custom route.
Can anyone help?
PS: I thought it might be the post not actually being set because of the custom route, so I've tried setting the global post dynamically based on the route provided - i.e. post will either be a single wine or a single winerange dependent on the route.
But this didn't work either...
-
How to create a widget using Rest API in WordPress
I want to create a widget using Rest API in WordPress, that widget can integrate in any WordPress site. I have an API which produce some data
When user search some text on my widget than that widget can hit my third party api get response and show it our search area
need help
-
ACF Advanced Custom Field Multiplication returning 0 instead of the correct math answer
I am trying to do all manner of things with the ACF Advanced Custom fields. In this case I created two custom fields
<?php $num1 = get_field('test_one'); $num2 = get_field('test_two'); $num3 = $num1*$num2 ; echo "</br> Value is $num3" ; ?>
test_one contains 2 as the default value, test_two contains 4 I am getting 0 as the result when clearly the field values should return something different.
What is going on here?
-
Wordpress ACF Repeater background image only loading last image
I have a slick carousel and I want the dots to dynamically display the image on the slide that is being displayed currently.
The image is coming dynamically through a Wordpress ACF Repeater, that I've placed in the head
Here's What the code in my head looks like:
<meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <style type="text/css"> <?php if( have_rows('testimonial_slides') ): ?> .testimonial_slider_dots li { background: #FFF0CE; height: 10px; width: 10px; border-radius: 50%; margin: 15% 0; } .testimonial_slider_dots .slick-active { <?php while( have_rows('testimonial_slides') ): the_row(); $icon = get_sub_field('testimonials_slide_product_icon'); ?> background: url('<?php echo $icon['url']; ?>'); <?php endwhile; ?> background-repeat: no-repeat !important; background-position: 50% 50% !important; background-size: cover !important; width: 50px !important; height: 50px !important; } <?php endif; ?> </style> @php wp_head() @endphp </head>
Here's my JS
$('.testimonials-slider').slick({ dots: true, arrows: false, infinite: true, //autoplay: true, slidesToShow: 1, adaptiveHeight: true, dotsClass: 'testimonial_slider_dots', responsive: [ { breakpoint: 768, adaptiveHeight: false, }, ], });
The image is displaying, but I'm only seeing the last image in the repeater, and not the specific image that matches the slide I'm currently seeing.
EDIT:
Here's the HTML:
<ul class="testimonial_slider_dots" style="display: flex;" role="tablist"> <li class="slick-active" role="presentation"> <button type="button" role="tab" id="slick-slide-control10" aria-controls="slick-slide10" aria-label="1 of 6" tabindex="0" aria-selected="true">1</button> </li> <li role="presentation"> <button type="button" role="tab" id="slick-slide-control11" aria-controls="slick-slide11" aria-label="2 of 6" tabindex="-1">2</button> </li> <li role="presentation"> <button type="button" role="tab" id="slick-slide-control12" aria-controls="slick-slide12" aria-label="3 of 6" tabindex="-1">3</button> </li> <li role="presentation"> <button type="button" role="tab" id="slick-slide-control13" aria-controls="slick-slide13" aria-label="4 of 6" tabindex="-1">4</button> </li> <li role="presentation"> <button type="button" role="tab" id="slick-slide-control14" aria-controls="slick-slide14" aria-label="5 of 6" tabindex="-1">5</button> </li> <li role="presentation"><button type="button" role="tab" id="slick-slide-control15" aria-controls="slick-slide15" aria-label="6 of 6" tabindex="-1">6</button> </li> </ul>
When the page loads, here's what the css looks like on inspect:
-
Wordpress search for author locations
I am building a website in WordPress with lots of authors. Now I'd like to create a search form where I can search for the authors, based on their location. So let's say I search for California (or postal code), I'd like to show all authors that live in a radius of 50km around California.
I created a google maps field with ACF for the authors, so they can fill in their address. To get their address information, I use:
$location = get_field('address', 'user_' . $user->ID);
I also created a page template 'page-authors', to show all authors:
$users = get_users(array( 'role__in' => [ 'author' ], 'number' => '-1', 'has_published_posts' => false )); <?php foreach ($users as $user) : ?> Here we can show the address with the code above. <?php endforeach; ?>
So now my question is: how can I use the Google Maps API in combination with the WordPress search engine to filter these users based on their location? What's the best approach? Please lead me in this, because I don't know where to start. Maybe someone have an example for this?
Thanks in advance!
-
(Updated) Get WooCommerce category on second language using WPML
I'm using WPML on my WordPress site with Spanish and English languages.
I need to retrieve WooCommerce products from a translated (English) category. This is my working code for the main language (Spanish):
// get all products from the category talleres $productos = wc_get_products([ 'status' => 'publish', 'limit' => -1, 'product_cat' => 'talleres' ]); // then get some information about each product in that category $locaciones = array_map(function ($product) { /** @var WC_Product $product */ return [ 'lat' => get_post_meta( $product->get_id(), 'lat_mapa_tl', true), 'long' => get_post_meta( $product->get_id(), 'long_mapa_tl', true), 'icono' => get_post_meta( $product->get_id(), 'icono_mapa_tl', true ), 'popup_html' => '<div class="titulo">' . $product->get_title() . '</div><br /><a href="' . get_permalink( $product->get_id() ) . '" class="sinborde"><img src="' . get_the_post_thumbnail_url( $product->get_id(), 'full' ) . '" width="250" height="141" title="Hacé click para ver el time-lapse" /></a><br /><div class="coleccion">Categorizado en ' . $product->get_categories() . '</div><a href="' . get_permalink( $product->get_id() ) . '">Ver time-lapse</a>' ]; }, $productos);
This is working perfectly. The problem comes when trying to use the translated category of talleres, which is "workshops". Using that category, this would be my code:
$productos = wc_get_products([ 'status' => 'publish', 'limit' => -1, 'product_cat' => 'workshops' ]);
But that gets the information from the original untranslated category in Spanish, not in English (my second language).
Edit:
Someone suggested I should add this line inside
wc_get_products
:'suppress_filters' => true
But that didn't work.
-
Wordpress same page with basic and /folder/ link
i would like to ask if there is a way to run this setup:
I have domain: example.org
I am using WPML plugin, the default language is English, i would like to set that example.org/en/ would be alias of abc.com and would point to this without any redirection. Basicly i am trying to run same page on example.org and example.org/en/ without any extra files or database.
I was trying to do something like this in my .htaccess but it's incorrect. Options +FollowSymLinks
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^/en/(.*)$ https://example.org/$1 [R=301,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
I don't have access to "alias" in server configuration and I wonder if it is possible to achieve.
-
How to translate custom plugin by creating .po and .mo file
Basically my requirement is to translate my custom plugin in dutch language for WPML. So when I change the language from english to dutch, It has to automatically change all the text of my plugin in admin panel. I am creating .po file from poedit software. It generates two files .po and .mo file. I put them in the plugin folder;
../wp-content/plugins/cleaner/languages/nl_NL.po ../wp-content/plugins/cleaner/languages/nl_NL.mo
Now I put this code in root file of the plugin.
add_action('init', 'cleaner_load_textdomain'); function cleaner_load_textdomain() { load_plugin_textdomain( 'cleaner' , false , basename(dirname(__FILE__)) . '/languages' ); }
But it is not doing anything. Any suggetions. Thanks in advance.