How to add a piece of code in function

if( in_array( ‘comments’,$meta_info ) ){ $key=”link”; echo ‘<span class=”post-meta-info with-cmt”>’ . apply_filters(‘yt_icon_comment’, ‘<i class=”fa fa-comments”></i>’) . ‘ ‘; comments_popup_link( __( ‘0 Comments’, ‘theme’ ), __( ‘1 Comment’, ‘theme’ ), __( ‘% Comments’, ‘theme’ )); echo ‘</span>’; echo ‘&nbsp;<a href=”‘. get_post_meta($post->ID, $key, true) .'” target=”_blank”>Images Source</a>’ . “\n”; } Try this code once. I modified the … Read more

Show the post date using the wp_get_archives() function?

wp_get_archives() can not display post date, but you can force wp_get_archives to display date by using hook. Put the following function at the end of your custom template file or functions.php file – function wpse_the_title($title, $id){ if( $date = get_the_date(‘d/m/Y’, $id) ){ $title = sprintf(‘%s – %s’, $date, $title); } return $title; } Replace with … Read more

Create input select image URL?

By Javascript you can pop-up the media and on select you can update the image URL to the textbox. Below is the code. var custom_uploader; jQuery(‘<Should-be-a-button-selector>’).click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen the dialog if (custom_uploader) { custom_uploader.open(); return; } //Extend the wp.media object custom_uploader = wp.media.frames.file_frame = wp.media({ title: … Read more

Allow the access over wp-login.php

Use the hook template_redirect instead – this will ensure it only runs on the front-end of your site, and not for the admin, login, registration or signup pages. function wpse_159552_maintenance() { if ( ! is_front_page() ) { wp_redirect( home_url() ); exit; } include ‘maintenance/index.html’; exit; } add_action( ‘template_redirect’, ‘wpse_159552_maintenance’ );

Force changing the Site Title and add link

add_filter(‘option_blogname’, ‘filter_name’); function filter_name($string) { return str_replace(‘original’, ‘replacement’, $string); } This code should work, as well as yours. But there’s one catch, you have to use get_bloginfo like this: echo get_bloginfo(‘name’, ‘raw’); If not, bloginfo sanitizes the output, and it eliminates the <a></a>. At the same time is someting good, because if not you would … Read more

Blank child theme – functions.php problem

I’ve created a child theme, and moved all the modifications I had in the parent theme functions.php into the child theme’s functions.php Don’t move all the functions from the parent theme into the child theme, just add the modifications to the child theme and leave the parent functions.php as it came with the theme. You … Read more

Register a widget area when a theme option has been saved?

In functions.php write this code function my_optionally_widgets() { $option = get_options(‘wantwidget’); if($option == ‘yes’) { register_widget(‘mywidget’); /* add other widgets for registration here */ } } add_action(‘widgets_init’, ‘my_optionally_widgets’); function my_optionally_sidebars() { $option = get_options(‘wantsidebar’); if($option == ‘yes’) { register_sidebar($args); /* add other sidebars for registration here */ } } add_action(‘init’, ‘my_optionally_sidebars’); Remember that Widget Areas … Read more