Peter
Forum Replies Created
-
Forum: Plugins
In reply to: [Rename Media Files: Improve Your WordPress SEO] Get back the post IDUpdate:
Unfortunately, I don’t get all ACF fields back. And I want to translate some fields by “if”.I use this code:
add_filter('frou_sanitize_file_name', function($filename_infs) { global $post; $p_id = $post['ID']; // Buy or rent $buy_rent = ''; if (get_field('buy_rent', $p_id) == 'buy') { $buy_rent = 'elado'; } else { $buy_rent = 'kiado'; } $filename_infs['structure']['translation']['my_custom_rule'] = $buy_rent.'-property-'.$p_id; return $filename_infs; }, 20);
UPDATE 2:
I got the ID with this:$p_id = \FROU\WordPress\Post::get_parent_post_id();
- This reply was modified 2 years ago by Peter.
Meanwhile, I realized that $post is not the post (property post_type), but the media file. ??
That’s why it didn’t work.Best regards,
PeterHello Jordy,
In the functions.php.
Your tutorial code works:
// Override the filename naming rules with this filter add_filter( 'mfrh_new_filename', 'my_filter_filename', 10, 3 ); function my_filter_filename( $new, $old, $post ) { // Get the date from the $post (which is the media entry) and convert it to a timestamp $post_date = strtotime( $post['post_date'] ); // Make this timestamp to looks like 2018-01-01 $formatted_date = date('Y-m-d', $post_date); // Add this timestamp in front of the filename already decided by Media File Renamer $new_filename = $formatted_date . "-" . $new; return $new_filename; }
But not mine. ??
– Peter
Hello Jordy,
Thanks for the answer.
But the code below doesn’t work.function custom_filter_filename($new, $old, $post) { $p_id = $post['ID']; $p_title = $post['post_name']; $buy_rent = get_field('buy_rent', $p_id); return $buy_rent.'-'.$p_title.'-'.$p_id.'.jpg'; } add_filter('mfrh_new_filename', 'custom_filter_filename', 10, 3);
I uploaded a picture. The name is Marbella-Property.jpg.
The plugin renamed it to: marbella-property.jpgBut that’s not good. This would be the correct new file name: sale-marbella-property-1458.jpg
The 1458 is the post ID.
Is my PHP code wrong?
Kind regards,
PeterDear Jordy,
What is the $new, $old and $post?
I saw a snipet:
$post_date = strtotime( $post['post_date'] );
I think I can recover the post ID by $post:$p_id = $post['ID'];
And an ACF field:$buy_rent = get_field('buy_rent', $p_id);
And from these I want to give a unique file name to the images.
$buy_rent.'-'.$p_title.'-'.$p_id.'.jpg';
E.g. sale_property_title_5455.jpg
Is it possible with the “mfrh_new_filename” hook?
Best regards,
Peter- This reply was modified 2 years ago by Peter.
Why don’t you answer the question??? Why don’t you indicate that the plugin is no longer supported???
I made a new website without knowing that support for this plugin was finished. Now I have to remake this website with another plugin.Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] Custom taxonomy #2Another solution?
– Peter
Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] Custom taxonomy #2Hi VaLeXaR,
I cleared all cache. The problem has NOT resolved.
– Peter
Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] Custom TaxonomyHi VaLeXaR,
I set the new taxonomy and post type in the wpm-config.json file, but the doesn’t show the language switcher in the new post type and taxonomy page.
The wpm-config.json file is in my template root.{
“post_types”: {
“mobel”: {},
},
“taxonomies”: {
“mobel_cat” : {},
},
}Best regards,
PeterForum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] ACF Options page configHi VaLeXaR,
The ACF Options page id is 12810 (or toplevel_page_theme-special-settings). But the language switcher isn’t in the ACF Options page?
My code:
{
“admin_pages”: [
12810,
“toplevel_page_theme-special-settings”
],
},- This reply was modified 6 years, 8 months ago by Peter.
Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] ACF Options page configHi!
I put this code into the .json file:
{
“admin_pages”: [
“toplevel_page_theme-special-settings”,
],
}And there is not language switcher. ??
Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] Contact Form 7Hi VaLeXaR,
i put this code into the wpm-config.json, but the error message is duplicated.
{
“post_types”: {
“wpcf7_contact_form”: null
},
“post_fields”: {
“_form”: null,
“_mail”: null,
“_mail_2”: null,
“_messages”: null
}
}The error message: [:HU]DAS FELD IST ERFORDERLICH.[:DE]DAS FELD IST ERFORDERLICH.[:]
– Peter
Forum: Plugins
In reply to: [WP Multilang - Translation and Multilingual Plugin] Doesn’t work for meThank you VaLeXaR!