WordPress codex for page
How to get the current page slug?
global $post; $slug = get_post( $post )->post_name;
# 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; }
Before we start please do support my Youtube channel Web Developer Green – https://www.youtube.com/channel/UCSilTsUejzMeHJ8rSvp2K_g master, thank you! HTML CODE <div class="r-faq"> <div class="r-wrap"> <h2>Top Questions, our customers Ask</h2> <div class="faq-q active">what is slow roasting? <i class="fas fa-plus"></i></div> <div class="faq-a" style="display:block;">Slow roasting is always better. The slower we bring the beans to temperature, the more consistent…
Add sub-page using 1 page without adding another pages using add_rewrite_rule is very simple but clean strategy most specially if you have multiple sub-pages. Using add_rewrite_rule, your task is done. Please copy the codes to your functions.php. Example: I have this page, https://www.anthonypagaycarbon.com/parent/ and the page ID is 10. [php] add_filter(‘query_vars’, ‘wdes_query_vars’); function wdes_query_vars($vars) {…
How to get the current scroll top position? Copy and past the following codes below to your JS file. var current_scroll = window.scrollY; console.log( current_scroll );
The7 social network share button open new window instead of new tab. Copy the codes below to your JS file. $('.soc-ico a' ).click(function(e){ e.preventDefault(); window.open(this.href, "myWindowName", "width=800, height=600"); });