Tagged: custom field, gravity forms
-
AuthorPosts
-
February 7, 2024 at 6:53 pm #1433535
Hi Enfold,
If I editing a post in wordpress backend with the Default Editor, I can choose on the Custom Field “Feature Image” between the options “Show on single entry” or “Hide on single entry”.
GravityForms with the “Advanced Post Creation” Add-On, allows to create posts and insert Custom Files field into the form, so the user can choose between the various options.
But the Custom Field “Featured Image” does not appear in the list of Custom Fields :(Can you tell me where I’m wrong?
Why can I see the Enfold Custom Field “header_title_bar”, “header_transparency”, but not “Feature Image”?Best regards,
OrianoFebruary 8, 2024 at 10:12 am #1433633Hey Oriano,
Thank you for the inquiry.
The Featured Image option is only available for posts or portfolio items. If you want to add this option to your own custom post type, you can use the avf_display_featured_image_posttypes filter in the functions.php file.
add_filter('avf_display_featured_image_posttypes', function($post_types) { $post_types[] = 'your_post_type'; return $post_types; }, 10, 1);
Best regards,
IsmaelFebruary 8, 2024 at 3:43 pm #1433706Hi Ismael, thanks for your answer.
I entered your code, but inside the Gravity Post Creation I still only see this Custom Fields :(
- breadcrumb_parent
filesize
footer
footer_behavior
footnotes
header_title_bar
header_transparency
layout sidebarI don’t see the Enfold Custom Field featured_image that should allow me to select between the option “Show on single entry / Hide on single entry”.
Best regards,
OrianoFebruary 9, 2024 at 8:19 am #1433771Hi,
Thank you for the update.
The Featured Image settings should display inside the Layout metabox just under the Header visibility and transparency settings. If you want to control it manually, you can add a new custom field called _avia_hide_featured_image and set the value to true or false.
Best regards,
IsmaelFebruary 9, 2024 at 9:29 am #1433777Hi Ismael, thank you for your answer,
The Featured Image settings should display inside the Layout metabox just under the Header visibility and transparency settings.
yes I saw this.
But I need to give the possibility to choose to show or hide the Featured image of the post also to the user who creates a new Post via Gravity Forms.I then entered on the child theme function the code:
add_filter('avf_display_featured_image_posttypes', function($post_types) { $post_types[] = 'your_post_type'; return $post_types; }, 10, 1);
then I add the custom field “_avia_hide_featured_image” and edit Value “true”, but the response I get is “Please provide a custom field value.” :(
Find some private data below.
Best regards,
OrianoFebruary 9, 2024 at 10:38 am #1433783Hi,
But I need to give the possibility to choose to show or hide the Featured image of the post also to the user who creates a new Post via Gravity Forms.
We are not entirely clear on how that works. Could you please explain further?
Did you replace the placeholder “your_post_type” with the actual name of the post type?
add_filter('avf_display_featured_image_posttypes', function($post_types) { $post_types[] = 'your_post_type'; return $post_types; }, 10, 1);
then I add the custom field “_avia_hide_featured_image” and edit Value “true”, but the response I get is “Please provide a custom field value.”
Could you please provide a screenshot or a short clip of the error, or the input field where you entered the custom field?
Best regards,
IsmaelFebruary 9, 2024 at 10:40 am #1433784Hi,
Have you tried selecting Add New Custom Field Value Name from the dropdown (https://img.savvyify.com/image/9vVsp)? Then place true or false in the Value field.
Best regards,
IsmaelFebruary 9, 2024 at 11:20 am #1433790Ismael, now this happens.
I created a post via the Gravity Form (I choose the value “false” in the _avia_hide_featured_image custom field), submit the form, and the post is saved as a draft.
Then from the Dashboard / Posts panel, I select “Preview” of the post, the browser one a page wiithe the preview of the post, an the Featured Image not displayed. Well.
But, but… when I “edit” the Post to publish it online or to schedule it online on a specific date, and save the post, the featured image appears in the post view :(I hope I explained myself :(
Could you please provide a screenshot or a short clip of the error, or the input field where you entered the custom field?
Here the error
Best regards,
OrianoFebruary 9, 2024 at 11:31 am #1433795Hi Ismael,
please see the screenvideo you find in Private Content.Best regards
OrianoFebruary 11, 2024 at 7:53 pm #1434019Hi,
Thanks for the video, I’m not sure how your plugin works, but your test post is a Block Editor post on the backend, but if I publish it it seems to be a ALB post on the frontend, so I believe this causes an issue. Similar to if you try to switch editors after a post is created, this often causes errors with the content.
If you don’t want the featured image to show you can use this css to hide it:.single-post .big-preview.single-big { display: none; }
This might be the best way to work around this.
Best regards,
MikeFebruary 12, 2024 at 8:35 am #1434060Hi Mike, thanks for help
If you don’t want the featured image to show you can use this css to hide it:
my problem is that the user who submits a post on the Enfold blog via Gravity Forms & Advanced Post Creation Add-On, should be able to choose whether the post should have the featured image or not :(
Please also watch the video (see link on Private content), where if I try to add the costum field directly from the WordPress editor, I receive an error, so maybe I’m doing something wrong?
Best regards,
OrianoFebruary 12, 2024 at 12:21 pm #1434076Hi,
In my research I fould the custom fields that begin with an underscore are hidden custom fields and are not displayed in the WordPress edit post page and can only be updated programmatically.
This is why you can not add it manually, I found and function that will allow the field to be shown, but you still can not manually update it:add_filter( 'is_protected_meta', function( $protected, $meta_key, $meta_type ) { $allowed = array( '_avia_hide_featured_image', '_test', '_wp_page_template' ); if( in_array( $meta_key, $allowed ) ) return false; return $protected; }, 10, 3 );
See these pages for reference:
https://melapress.com/support/kb/wp-activity-log-log-changes-hidden-custom-fields/
https://wordpress.stackexchange.com/questions/116534/how-to-allow-hidden-custom-fields-to-be-added-from-wp-admin-post-phpPerhaps your best solution will be to create a new custom field that will add a custom class to the page body and then use css to hide the featured image when ever the class is on the page.
Best regards,
MikeFebruary 13, 2024 at 9:34 am #1434159Hi Mike, thanks for your help
Perhaps your best solution will be to create a new custom field that will add a custom class to the page body and then use css to hide the featured image when ever the class is on the page.
yes, I think I will try to implement this solution.
Can you please tell me, if you know, where I can find instructions on how to do this, possibly without using a plugin.
(If you can’t answer this question, I understand… it’s likely that this is not the scope of Enfold support).Best regards,
OrianoFebruary 13, 2024 at 12:39 pm #1434174Hi,
I don’t know about your plugin so I don’t know how the form that you have created will be able to add to a custom field.
But this post will explain how to use the add a custom field to add a custom body class.Best regards,
MikeFebruary 14, 2024 at 10:23 am #1434268Hi Mike, thanks for your help,
your “best solution” work fine.Perhaps your best solution will be to create a new custom field that will add a custom class to the page body and then use css to hide the featured image when ever the class is on the page.
Best regards,
OrianoFebruary 14, 2024 at 12:16 pm #1434287Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Custom Field “Hide on sigle entry”, and Gravity Forms’ is closed to new replies.