Can’t Update function.php after writing short code

The answer by @motivast is correct. However, to avoid using a billion echo and apostrophes, you can simply close the PHP tag and open it after your script: function wpse_287665_mobile_menu_script() { ?> <script> jQuery(document).ready(function($){ $(“button.menu-toggle”).click(function(){ if( $(“button.menu-toggle”).attr(“aria-expanded”) == “true” ) { $(“button.menu-toggle”).attr(“aria-expanded”, “false”); $(“ul#top-menu”).attr(“style”, “display:none;”); } else { $(“button.menu-toggle”).attr(“aria-expanded”, “true”); $(“ul#top-menu”).attr(“style”,”display:block;”); } }); }); </script><?php … Read more

HTML table from shortcode with multiple parameters

I have created an example of how you can achive what you are after: You can use it like this : [itable data=”inv;coin;coinamount;currency#inv;coin;coinamount;currency”] function itable_shortcode( $atts ) { extract( shortcode_atts( array( ‘data’ => ‘none’, ), $atts ) ); $data = explode(‘#’,$data); $output = “”; foreach ($data as $value) { $output .= ‘<tr>’; $in_value = explode(‘;’,$value); … Read more

Using the child theme functions.php to change the customizer.php on parent theme

Put this code in function.php. create custom section in customizer for logo : <?php add_action(‘customize_register’, ‘theme_footer_customizer’); function theme_footer_customizer($wp_customize){ //adding section in wordpress customizer $wp_customize->add_section(‘footer_settings_section’, array( ‘title’ => ‘Footer Text Section’ )); //adding setting for footer logo $wp_customize->add_setting(‘footer_logo’); $wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize,’footer_logo’,array( ‘label’ => ‘Footer Logo’, ‘section’ => ‘footer_settings_section’, ‘settings’ => ‘footer_logo’, ))); }

how to use preg_replace for wordpress video?

So you’re using the default WordPress video shortcode in the editor, right? If so, there’s no need to filter the whole content, especially that markup for the video would be already rendered and is quite complicated: <div style=”width: 960px;” class=”wp-video”><!–[if lt IE 9]> <script>document.createElement(‘video’);</script><![endif]–> <video class=”wp-video-shortcode” id=”video-160186-1″ width=”960″ height=”600″ preload=”metadata” controls=”controls”> <source type=”video/mp4″ src=”https://wordpress.stackexchange.com/questions/300917/YOUR_VIDEO_URL” /> … Read more

How to change menu icon which is overriden (i.e. by WooCommerce) [closed]

WooCommerce styles the icon via this CSS file: woocommerce/assets/css/menu.css, and here’s the corresponding code (pretty-printed or actually, I copied it from woocommerce/assets/css/menu.scss): #adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before { font-family: ‘WooCommerce’ !important; content: ‘\e03d’; } So you can change the font-family and the content (and other) properties to suit your custom icon. Below is an example of … Read more

Problems with function on function.php

Did you try to use add_action without priority? On the last line, you specify the priority. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. function test_1234567() { // Get term by name ”news” in Categories taxonomy. $category = … Read more

Best practice custom function, where to echo the variables?

Generically speaking, yes. If your normal output would be to echo at the end, echoing during the loop wouldn’t change much. function get_some_posts($args) { $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); the_title(); // the_title() is the same as echo get_the_title(); } } } add_action(‘custom_hook’,’get_some_posts’); The … Read more

change billing and shipping address 1 and 2 field placeholders [closed]

Prior to the address fields being passed through the woocommerce_checkout_fields hook, they are retrieved by WC_Countries::get_address_fields(), and inside that function there is a comment before its filter that reads: Important note on this filter: Changes to address fields can and will be overridden by the woocommerce_default_address_fields. The locales/default locales apply on top based on country … Read more