kevinselectos
Forum Replies Created
-
Forum: Plugins
In reply to: [Optimole – Optimize Images in Real Time] Get default url in backendHi @bvytis,
My bad, I didn’t see the URL exclusion setting. Thanks for your help, everything is working fine now.
Have a good day !
Forum: Plugins
In reply to: [Optimole – Optimize Images in Real Time] Get default url in backendHi @bvytis ,
Any news ?
Forum: Plugins
In reply to: [Optimole – Optimize Images in Real Time] Get default url in backendHi @bvytis,
Here is the full code:
add_action('rest_api_init', function () { register_rest_route( 'westland/v1', 'shops',array( 'methods' => 'GET', 'callback' => 'get_all_shops' )); }); function get_all_shops(){ $output = array(); $shops = new WP_Query(array( 'post_type' => array('commerces','restaurants'), 'posts_per_page' => -1, 'order' => 'DESC', )); if (empty($shops->posts)) { return new WP_Error( 'empty_category', 'There are no posts to display', array('status' => 404) ); } foreach($shops->posts as $shop){ $id = $shop->ID; $logoColor = ""; $logoWhite = ""; preg_match('/.+(https[:\/\/]*westland.+)/',get_field("shop-logo-couleur",$id),$logoColor); preg_match('/.+(https:\/\/westland.+)/',get_field("shop-logo-blanc",$id),$logoWhite); array_push($output,array( 'basic'=>array( 'id' => $id, 'name' => get_field("shop_name",$id), 'description' => get_field("shop_description",$id), 'logoColor' => $logoColor[1], 'logoWhite' => $logoWhite[1], 'category' => get_the_terms($id,'shops_cats')[0]->name, 'type' => $shop->post_type, 'pageURL' => get_permalink($id), 'giftCard' => get_field("gift_card_participation",$id), ), )); } $response = new WP_REST_Response($output); $response->set_status(200); return $response; }As you can see, the goal is to create a REST endpoint to display store data in JSON format.
But when I’m calling this endpoint, I can see that the value of logoColor is null for every shop.
I just tried to log the value of the get_field() function with error_log(), and it correctly returns the default URL. So I assume the modification is done when the endpoint is called. How can I prevent optimole from changing the URL of this endpoint ?
And one last thing, can I do it directly on the live version of our site? Is there a risk of breaking our site (obviously I’ll do a backup first) ?
Hi @onlyincebu
I did everything up to the 3rd step, it works and all the pages have the correct title.
But I’m not sure I understand the last step, are you talking about the “Start SEO Data Optimization” button ?
Thank you for your help.
@devnihil Maybe it’s better if I tag you, sorry I forgot.
Hi devnihil,
I spoke with our host support, cleaned the cache and the problem was still the same.
In addition, the problem also appears on the Staging version of our site and the cache is not activated on the Staging.
Then I tried disabling all plugins except YOAST and enabling the default theme twenty-twenty. The problem is still there.
You can see an example here:
https://staging-selectos.kinsta.cloud/meilleures-lampes-de-lecture/If I look in the edit page of this article, the meta title field is set to “%% title %% %% page %% 2021 [Comparatif] – Selectos”. But on the page, it’s always “%% title %% %% page %% 2020 [Comparatif] – Selectos”
- This reply was modified 5 years, 2 months ago by kevinselectos.