Tagged: child theme, functions.php
-
AuthorPosts
-
February 6, 2019 at 3:32 pm #1063657
Hi,
I am trying to add custom code to the functions.php / functions-enfold.php (I’ve tried both), but it seems to get ignored.I want the search engine to also look through posts. I am using Relevanssi as a search engine and added the required code. However, that code get’s ignored.
What can I do to fix this?
February 8, 2019 at 1:12 pm #1064565Hi,
I’ve continued working on this: Switching the theme and switching back as well as clearing the cache. That didn’t help.Thought I’d let you know and looking forward to your reply!
February 9, 2019 at 4:37 am #1064853Hi 4cprintsolution,
I tried the login credentials you gave, however it doesn’t work, please check.
Does it work when using the default wordpress theme?
Also when using Enfold try adding this in functions.php:function custom_stuff(){ ?> <div style="display:none">Find this</div> <?php } add_action('wp_footer', 'custom_stuff');
Then view the page source and try to find
Find thisif you can check it there then it surely works.
Best regards,
NikkoFebruary 13, 2019 at 6:08 pm #1066565Hi,
thank you for your reply!I’ve checked the credentials, they work.
I’ve tried changing to twentynineten – the search worked as intended there – and switched back.
Nope, I wasn’t able to find this by adding the code to functions.php nor functions-enfold.php. This is my functions.php:
<?php /* * Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then. */ // Bringt Widget Area in den Header neben das Logo add_action( 'ava_before_bottom_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { dynamic_sidebar( 'header' ); } // remove default sorting dropdown in StoreFront Theme function avia_woocommerce_frontend_search_params() { return; } // Button Text beim bestellen add_filter( 'woocommerce_order_button_text', 'mmx_order_button_text' ); function mmx_order_button_text() { return __( 'Kostenpflichtig bestellen', 'woocommerce' ); } // remove related product on product site /*function avia_remove_related_product() { remove_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_output_related_products', 20); } add_action( 'init', 'avia_remove_related_product');*/ // Titel auf Produktseite add_filter( 'avf_title_args', 'avf_product_titlee', 0, 2 ); function avf_product_titlee( $args, $id ) { if ( is_singular('product') ) { $args['title'] = get_the_title($id); } return $args; } // add post type product add_action('ava_frontend_search_form','ava_frontend_search_form_mod'); function ava_frontend_search_form_mod() { echo '<input type="hidden" name="post_type" value="product">'; } add_action('woocommerce_after_add_to_cart_button','cmk_additional_button'); function cmk_additional_button() { echo '<button class="popmake-3546" id="button-angebot" data-do-default="">Ja, bitte senden Sie mir ein Angebot zu!</button>'; } add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); function custom_price_message( $price ) { $new_price = $price . ' <span class="custom-price-prefix">' . __('<br> >> JETZT ANSEHEN >>').'</span>'; return $new_price; } add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1 add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 + function woo_custom_single_add_to_cart_text() { return __( 'In den Warenkorb legen', 'woocommerce' ); } function ava_woocommerce_after_cart_mod( ) { echo '<div class="after_cart"><span class="waren"><h3>Bequem und sicher bestellen</h3><br><h4><span style="color: #009900">✔</span> Bezahlung:</h4>Bequem auf Rechnung, PayPal, Sofortkauf oder Vorkasse<br><br><h4><span style="color: #009900">✔</span> Produktion:</h4>Sie erhalten vorab einen Korrekturabzug als PDF oder eine fertige Mustertasse.<br><br><h4><span style="color: #009900">✔</span> Lieferzeit:</h4>Wir brauchen ca. 5 Tage für die Produktion nach Druckfreigabe.</span></div>'; }; add_action ('woocommerce_after_cart', 'ava_woocommerce_after_cart_mod', 100, 0 ); add_action( 'after_setup_theme', 'mmx_avia_woocommerce_settings' ); function mmx_avia_woocommerce_settings(){ global $avia_config; $avia_config['shop_single_column_items'] = 5; $avia_config['shop_single_column'] = 5; } add_action('init', 'avf_move_product_output'); function avf_move_product_output() { remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 ); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 5 ); } add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 ); function remove_add_to_cart_buttons() { if( is_product_category() || is_shop()) { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); } } // Magazinartikel mit in Suche aufnehmen add_filter( 'relevanssi_modify_wp_query', 'rlv_force_post_product' ); function rlv_force_post_product( $query ) { $query->query_vars['post_types'] = 'post,product'; return $query; } // Display 240 products per page. Goes in functions.php add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 240;' ), 20 ); add_filter('comments_open','__return_false', 10, 2); /*add_action('ava_before_footer','avia_above_footer'); function avia_above_footer(){ dynamic_sidebar( 'above footer' ); }*/ function custom_stuff(){ ?> <div style="display:none">Find this</div> <?php } add_action('wp_footer', 'custom_stuff');
What do we do? :-)
February 16, 2019 at 5:44 pm #1067732Hi 4cprintsolution,
I don’t see the code Vinay suggested. Did you have it removed?
Best regards,
VictoriaFebruary 16, 2019 at 9:38 pm #1067803Hi Victoria,
no, I didn’t. It’s right at the end of the code I’ve shared.:-(
Best regards,
FranzFebruary 18, 2019 at 9:52 am #1068219Hi Franz,
Where did you add this code?
add_filter( 'relevanssi_modify_wp_query', 'rlv_force_post_product' ); function rlv_force_post_product( $query ) { $query->query_vars['post_types'] = 'post,product'; return $query; }
I can’t seem to find it in functions.php in both the child and parent theme.
Best regards,
NikkoFebruary 18, 2019 at 7:11 pm #1068538Hello Nikko,
it’s right here: https://imgur.com/a/8A0CfkoYou can find it by using CTRL + F. I think we are misunderstanding each other – I don’t understand what the hold-up is.
It’s been 12 days since I’ve opened this ticket – and 5 days of those we didn’t move an inch forward. I am quite frustrated. Is this the right place to get support for Enfold?
Please don’t misunderstand me – I am not trying to be bitter or cynic, but I don’t understand what the hold-up is. :-I
February 19, 2019 at 1:48 am #1068691Hi 4cprintsolution,
What we meant was in your WordPress Dashboard, if we go to Appearance > Editor > (Enfold Child selected) > Theme Functions (functions.php) this is the code I see: https://pastebin.com/QV66RSBL
What you posted in the thread isn’t found in functions.php, yes we can see the code in the thread but not in functions.php of your site.
Trying to add it there gives this error:Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.
Best regards,
NikkoFebruary 26, 2019 at 5:28 pm #1071886Hi Nikko,
thank you, now I understand. I’ve been using WINSCP to look at the file, you’ve been going through Design –> Editor.Good – I can recreate the behaviour you are seeing. However, I also am able to upload modified functions.php without problems to the server. But then WordPress seems to ignore them. And somehow uses different version than the ones on the FTP-Server.
I’ve used WP Healthcheck to test wether the Loopback Requests fail – they do.
- This reply was modified 5 years, 8 months ago by 4cprintsolution.
February 28, 2019 at 8:31 am #1072536Hi 4cprintsolution,
I tried to check it again however the code doesn’t appear in functions.php (checked this via Appearance > Editor).
What appears there is what you’re site currently use, maybe there’s some permission issue or maybe you can ask your webhost to help with it.Best regards,
NikkoMarch 4, 2019 at 7:49 pm #1074493Hi Nikko,
thank you. It’s hosted with checkdomain.de. We’ll ask them.March 5, 2019 at 11:12 am #1074775Hi 4cprintsolution,
Thanks, we’ll leave this thread open until then :)
Best regards,
NikkoMarch 6, 2019 at 7:50 pm #1075599Hi!
It seems to be a problem with the host, you are right.Meanwhile I’ve added the functions to a plugin and uploaded that.
You can find it here: https://www.kaffeebecher24.de/wp-admin/plugin-editor.php?plugin=relevanssi-artikel-aufnehmen%2Frelevanssi-artikel-aufnehmen.php&Submit=Ausw%C3%A4hlen
You will also find the code you asked me to add there as well as in the pages source code.
So, we are one step ahead. Yay! :-)
Now… how do we get the search engine to search through products and posts?
March 12, 2019 at 5:12 am #1077624Hi 4cprintsolution,
I apologize for the delayed response.
I tried the code you gave on my local server and it doesn’t seem to work even when I used twentynineteen, can you try using this code:add_filter( 'pre_get_posts', 'custom_post_type_search' ); function custom_post_type_search( $query ) { if ($query->is_search) { $query->set('post_type', array( 'post', 'product')); } return $query; }
Best regards,
NikkoMarch 12, 2019 at 12:22 pm #1077797Hi,
thank you. I’ve implemented the code and it’s working.March 13, 2019 at 8:13 pm #1078380Hi 4cprintsolution,
Glad we could help :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.