Marc Mathys
Forum Replies Created
-
AuthorPosts
-
February 1, 2017 at 10:47 am in reply to: Search in CPT with WPML from home page -> goes to wrong language #353007This reply has been marked as private.January 31, 2017 at 12:03 pm in reply to: Custom field (multi-select) not translating (WPML) with only one option checked #352470This reply has been marked as private.January 31, 2017 at 11:50 am in reply to: User submitted post come with wrong country language (WPML) #352465This reply has been marked as private.January 31, 2017 at 11:40 am in reply to: CPT Category URL broken with: WPML & Location Filter & disable physical location #352463
Hi Kiran,
Thank you, I copied it over (but can’t test yet on the live site). I’ll post again here if it doesn’t work.
Best,
MarcJanuary 31, 2017 at 11:27 am in reply to: Search in CPT with WPML from home page -> goes to wrong language #352462This reply has been marked as private.January 26, 2017 at 8:33 pm in reply to: CPT Category URL broken with: WPML & Location Filter & disable physical location #350026Hi Kiran,
Great, I removed my hacks and it works fine. How do I move the fix to my production site ? Note that Stiofan made some other changes related to WPML on my production site, so copying the plugin directory (or even entire file) might not be a good idea. Could you please send specific information, or apply it to the production site as well ? I can give you credentials. Let me know.
Best,
MarcJanuary 26, 2017 at 9:29 am in reply to: CPT Category URL broken with: WPML & Location Filter & disable physical location #349684This reply has been marked as private.Hi Guust,
As I moved from test site to staging site, I had to go through it again with new CPT. If slugs are only translated like you documented, there are definitely major issues left, even after resaving permalinks. For example:
1. the links on the categories widget sill have the English slug when the site is in another language
2. going on a category’s page and switching language with the WPML language selector still goes to the wrong language CPT slug
3. going on a listing in a foreign language and clicking on a category link, will have the wrong language in slug and yield to a 404
4. going on a listing’s page in English and switching language with the WPML language selector still go to the right language CPT slug, but the URL will miss all the location slugsTranslating the CPT slug that appear in WPML String Translation under the “WordPress” Domain fixes all 4 issues.
Cheers,
Marc😉
I do remember trying to re-save permalinks and it didn’t work. And you’re right, I did have 2 issues at once, renaming places and not manually matching the slug from CPT with the GD prefix was what caused the 404.
Hi Guust,
Thanks, great initiative. I think there might be an important point missing from the documentation: doing only the translation in WPML Translation Manager for CPT did NOT work for me (if I wanted to keep the location in the URL). I had to also go into WPML String Translation and translate the multiple instances of the slugs.
If I remember correctly:
– WPML Translation Manager -> translated the French slug of the listing, but removed the location from the URL (only in French, English was still fine). So it went from /fr/cpt_slug/country/region/city/listing to /fr/cpt_slug/listing
– WPML String Translation -> translating all instances of slugs as well fixed that problemBest,
MarcOK I found the solution to translating the CPT slugs without losing the entire location in the URL:
The slugs need to be translated in 2 places:
– once for CPT, like described here: https://wpgeodirectory.com/support/topic/translating-main-category-post-type-in-the-url/#post-44802
– and multiple times in the WPML String Translation tool. I searched for my slug with exact match and translated 3 entries:
– 2 in WordPress domain named “URL slug: stores” and “URL slug: gd_place”
– 1 in geodirectroy domain with the Context “URL slug”And now it works. Case solved, but painful process when undocumented.
I found the issue causing the 404 error:
Once Places gets renamed Stores in the CPT plugin and the slug changed to “stores”, it doesn’t automatically rename the “Listing url prefix” setting on the Permalinks page of the main GD plugin. This needs to be manually edited to match the slug name of the new Places (stores in my case).
Then translating the slug with WPML works, but doing so removes the entire /country/region/city/ off the URL even if settings are correct on the Permalinks page.
I undid WPML slug translation and the 404 are gone for now.
Only issue is that it says “Store” all over the French site.
The “urgent” in the title can be downgraded, sorry.This reply has been marked as private.January 10, 2017 at 12:44 pm in reply to: Popular Categories CPT selector not appearing in certain widget location #340261Hi Giri,
Fantastic, thank you. It still needed the change to this line
if ( count( $b_terms ) > 1 || $all_cpt ) {
, but now it works. I’m attaching the whole code below if anyone wants to do the same.
I’ll include this function in the plugin I’m building to bring Supreme Directory onto the KLEO theme as a plugin, rather than a child theme of Directory Starter (best of both worlds in my opinion). By the way… since I’m not a coder, I don’t know how to build a settings page for a plugin, so is there a community where I should post my code for people to enhance it if they’re interested ?
Best,
Marc/********************************************************************** * Create a new shortcode based on [gd_popular_post_category] to list * categories, but with the option to list all CPT and always show the * CPT selector. This is customized version of the original shortcode * found in geodirectory_shortcodes.php **********************************************************************/ add_shortcode('sd_kleo_popular_post_category', 'new_popular_place_shortcodes'); function new_popular_place_shortcodes($atts) { ob_start(); global $geodir_post_category_str; $defaults = array( 'category_limit' => 15, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', 'title' => '', 'default_post_type' => '', 'parent_only' => false, /* Add CPT */ 'all_cpt' => false, /* End change */ ); $params = shortcode_atts($defaults, $atts, 'popular_post_category'); $params['category_limit'] = absint($params['category_limit']); $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); /* Add CPT */ $params['all_cpt'] = gdsc_to_bool_val($params['all_cpt']); /* End change */ sd_kleo_geodir_popular_post_category_output($params, $params); $output = ob_get_contents(); ob_end_clean(); return $output; } function sd_kleo_geodir_popular_post_category_output( $args = '', $instance = '' ) { // prints the widget global $wpdb, $plugin_prefix, $geodir_post_category_str; extract( $args, EXTR_SKIP ); echo $before_widget; /** This filter is documented in geodirectory_widgets.php */ $title = empty( $instance['title'] ) ? __( 'Popular Categories', 'geodirectory' ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) ); /* Adding the argument from CPT & changing the CPT scope */ $gd_post_type = geodir_get_current_posttype(); $all_cpt = !empty( $instance['all_cpt'] ) ? true : false; if ($all_cpt) { $gd_post_type = false; } else { $gd_post_type = geodir_get_current_posttype(); } /* End change */ $category_limit = isset( $instance['category_limit'] ) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; if ( ! empty( $gd_post_type ) ) { $default_post_type = $gd_post_type; } elseif ( isset( $instance['default_post_type'] ) && gdsc_is_post_type_valid( $instance['default_post_type'] ) ) { $default_post_type = $instance['default_post_type']; } else { $all_gd_post_type = geodir_get_posttypes(); $default_post_type = ( isset( $all_gd_post_type[0] ) ) ? $all_gd_post_type[0] : ''; } $parent_only = !empty( $instance['parent_only'] ) ? true : false; $taxonomy = array(); if ( ! empty( $gd_post_type ) ) { $taxonomy[] = $gd_post_type . "category"; } else { $taxonomy = geodir_get_taxonomies( $gd_post_type ); } $term_args = array( 'taxonomy' => $taxonomy ); if ( $parent_only ) { $term_args['parent'] = 0; } $terms = get_terms( $term_args ); $a_terms = array(); $b_terms = array(); foreach ( $terms as $term ) { if ( $term->count > 0 ) { $a_terms[ $term->taxonomy ][] = $term; } } if ( ! empty( $a_terms ) ) { foreach ( $a_terms as $b_key => $b_val ) { $b_terms[ $b_key ] = geodir_sort_terms( $b_val, 'count' ); } $default_taxonomy = $default_post_type != '' && isset( $b_terms[ $default_post_type . 'category' ] ) ? $default_post_type . 'category' : ''; $tax_change_output = ''; /* Adding the "or" if all_cpt is true, then display it anyhow */ if ( count( $b_terms ) > 1 || $all_cpt ) { /* End change */ $tax_change_output .= "<select data-limit='$category_limit' data-parent='" . (int)$parent_only . "' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; foreach ( $b_terms as $key => $val ) { $ptype = get_post_type_object( str_replace( "category", "", $key ) ); $cpt_name = __( $ptype->labels->singular_name, 'geodirectory' ); $tax_change_output .= "<option value='$key' " . selected( $key, $default_taxonomy, false ) . ">" . sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ) . "</option>"; } $tax_change_output .= "</select>"; } if ( ! empty( $b_terms ) ) { $terms = $default_taxonomy != '' && isset( $b_terms[ $default_taxonomy ] ) ? $b_terms[ $default_taxonomy ] : reset( $b_terms );// get the first array global $cat_count;//make global so we can change via function $cat_count = 0; ?> <div class="geodir-category-list-in clearfix"> <div class="geodir-cat-list clearfix"> <?php echo $before_title . __( $title ) . $after_title; echo $tax_change_output; echo '<ul class="geodir-popular-cat-list">'; geodir_helper_cat_list_output( $terms, $category_limit ); echo '</ul>'; ?> </div> <?php $hide = ''; if ( $cat_count < $category_limit ) { $hide = 'style="display:none;"'; } echo "<div class='geodir-cat-list-more' $hide >"; echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __( 'More Categories', 'geodirectory' ) . '</a>'; echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __( 'Less Categories', 'geodirectory' ) . '</a>'; echo "</div>"; /* add scripts */ add_action( 'wp_footer', 'geodir_popular_category_add_scripts', 100 ); ?> </div> <?php } } echo $after_widget; }
-
AuthorPosts