WordPress codex for page
How to get the current page slug?
global $post; $slug = get_post( $post )->post_name;
Copy and paste the codes below to your custom template. global $current_user; echo get_avatar( $current_user->ID, 150, "https://www.anthonypagaycarbon.com/wp-content/uploads/2016/05/logo.png" ); For more detailed information, please visit here https://codex.wordpress.org/Function_Reference/get_avatar. Happy coding 🙂
Where ‘style-woocommerce’ is the ID of your stylesheet and get_stylesheet_directory_uri().’/style-woocommerce.css’ is your .css DIR. wp_register_style( 'style-woocommerce', get_stylesheet_directory_uri().'/style-woocommerce.css' ); wp_enqueue_style( 'style-woocommerce' ); Function below is for woocommerce page css only. This will show on woocommerce pages else is not. add_action( 'wp_enqueue_scripts','home_scripts' ); function home_scripts(){ If( is_shop() || is_product_category() || is_product() ){ wp_register_style( 'style-woocommerce', get_stylesheet_directory_uri().'/style-woocommerce.css' ); wp_enqueue_style(…
How Convert string with unwanted character to slug, proper name, etc.? Try this code using http://phptester.net/. // Example 1 function cleantitle($string){ $string = str_replace(' ', '-', $string); $string = preg_replace('/[^A-Za-z0-9\-]/', '-', $string); return preg_replace('/-+/', ' ', $string); } $str_1 = 'Menstruation_Sisters_-_14'; echo cleantitle($str_1); // output will be "Menstruation Sisters 14" // Example 2 function cleantitleslug($string){…
🚀 Learn How to Create a Section Using Elementor | Web Development for Beginners Welcome to this step-by-step tutorial where you’ll learn how to create a beautiful, responsive section using Elementor – one of the most powerful page builders for WordPress! Whether you’re a beginner in web development or just starting to build your first…
# BODY CLASS ADD ONS add_filter('body_class', 'extra_body_class'); function extra_body_class($classes) { global $wp_query; // Add current slug on body class $current_id = $wp_query->post->ID; $post = get_post($current_id); $slug = $post->post_name; $classes[] = 'body-'.$slug; $classes[] = sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $current_id ) ) ); return $classes; }
function widget_first_last_classes($params) { global $my_widget_num; $this_id = $params[0]['id']; $arr_registered_widgets = wp_get_sidebars_widgets(); if(!$my_widget_num) { $my_widget_num = array(); } if(!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) { return $params; } if(isset($my_widget_num[$this_id])) { $my_widget_num[$this_id] ++; } else { $my_widget_num[$this_id] = 1; } $class = 'class="widget-' . $my_widget_num[$this_id] . ' '; if($my_widget_num[$this_id] == 1) { $class .= 'first '; } elseif($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id]))…