IN
MainLogo

Add given code on functions.php. If you don’t want to use any type of plugins for sitemap. So use this code and check your website’s sitemap after publish post. //Disable Default WP sitemap add_filter( ‘wp_sitemaps_enabled’, ‘__return_false’ ); //Sitemap function generate_sitemap($posts) { $sitemap = ‘<?xml version=”1.0″ encoding=”UTF-8″?>’; $sitemap .= ‘<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″>’; foreach ($posts as $post) { […]

Add post attribute to set or change something on post’s look using post template. You want to add post template section on custom theme. So use simple code on your WordPress’s Theme. How to Do Open functions.php file of active theme. function add_custom_post_template($post_templates, $wp_theme, $post, $post_type) { if ($post_type === ‘post’) { $post_templates[‘page-template1.php’] = ‘Post […]

Embed-Two-or-More-YouTube-Thumbnail-20022

You want to embed multiple YouTube video on post. So you can easily embed two or more videos using shortcode on WordPress post. How to Do Open functions.php file and paste code. function video_embed_shortcode($atts) { $atts = shortcode_atts(array( ‘ids’ => ”, ‘prev_label’ => ‘Official Video’, ‘next_label’ => ‘Full Audio’, ), $atts, ‘video_embed’); $videoIds = explode(‘,’, […]

Add given code on your website and make copy button for Div Content. JavaScript Code // Lyrics Copy Button var EngCopyLyrics = document.getElementById(“EngCopyLyrics”); if(EngCopyLyrics) { EngCopyLyrics.addEventListener(“click”, function() { var elemEng = document.getElementById(“spldivPrintLyrics”); var textEnglish = elemEng.innerText; navigator.clipboard.writeText(textEnglish); var EngcopyMessage = document.getElementById(“EngcopyMessage”); EngcopyMessage.style.display = “inline”; setTimeout(function() { EngcopyMessage.style.display = “none”; }, 2000); }); } Button <button […]

This code for shortcode, You can make own functions’s shortcode. <?php function thekroyaard_shortcode(){ return ‘<div> This is Example </div>; } add_shortcode(‘short_code_name’, ‘thekroyaard_shortcode’); ?> What is changeable <div> …. </div> add or input any text or function for showing when paste shortcode. short_code_name write any name for shortcode, and paste this where you want to show […]

Paste this code on functions.php and automatically set meta description on Post. function add_meta_description_thekroyaard() { if (is_single()) { $post = get_post(); $excerpt = strip_tags($post->post_excerpt); if ($excerpt == ”) { $excerpt = strip_tags($post->post_content); $excerpt = substr($excerpt, 0, 160); $excerpt = substr($excerpt, 0, strripos($excerpt, ” “)); $excerpt .= “…”; } echo ‘<meta name=”description” content=”‘ . $excerpt . […]

Show google ads when heading4 available otherwise showing ads on bottom of content- function thekroyaard_ads_heading_4( $content ) { $ad_code = ‘ <div class=”thekroyaard_ads_heading_3″> <script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxxxx” crossorigin=”anonymous”></script> <ins class=”adsbygoogle” style=”display:block” data-ad-client=”ca-pub-xxxxxxxxxxxxxxxx” data-ad-slot=”xxxxxxxx” data-ad-format=”auto” data-full-width-responsive=”true”></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div>’; if ( is_single() ) { return ads_insert_after_paragraph( $ad_code, 1, $content ); } return […]

Paste this code for where you want to show latest post. <?php $the_query = new WP_Query( ‘posts_per_page=5’ ); while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></div> <?php endwhile; wp_reset_postdata(); ?>

php-Code-for-Comment-Validator

Add this code on functions.php. And make human validation function when someone do comment on your post. function validator_for_comments() { $a = rand(1, 100); $b = rand(1, 100); $c = $a + $b; echo ‘<p class=”comment-form-math”>’; echo ‘<label for=”comment_math”>’ . __(‘What is ‘ . $a . ‘ + ‘ . $b . ‘?’) . ‘</label>’; […]

Use this code on functions.php, then paste [show_last_week_populer] shortcode for showing last week’s popular Items. function popular_posts_last_week() { global $wpdb; $most_visited_posts = $wpdb->get_results(“SELECT p.ID, p.post_title, pm.meta_value AS ‘views’ FROM {$wpdb->prefix}posts AS p JOIN {$wpdb->prefix}postmeta AS pm ON p.ID = pm.post_id WHERE p.post_status = ‘publish’ AND p.post_type = ‘post’ AND pm.meta_key = ‘post_views_count’ AND DATE_SUB(CURDATE(), INTERVAL […]

Use this code for set automatically thumbnail without plugins – //Automatic Thumbnail when embed YT videos lite or standard version function set_automatically_featured_image_from_embed_YT_videos_thekroyaard($post_ID) { if (!has_post_thumbnail()) { $post_content = get_post_field(‘post_content’, $post_ID); $alt_name_make = get_post( $post_ID )->post_title; $auto_alt_id = get_the_ID(); $alt_name_YT = wp_trim_words( $alt_name_make, 5, $more = __( ‘ ‘.’ Thumbnail ‘. $auto_alt_id ) ); $alt_name_YT = […]