Posts

Showing posts from 2016

Change wordpress logo in admin login or register page

We can easily change WordPress logo on the Admin Login or Register page using below PHP function. Copy the given code in your active themesfunctions.php file. Do note forgot to change logo url with your logo having correct path, and store logo accordingly :
function custom_admin_login_logo() { ?> <style type="text/css"> body.login div#login h1 a { background-image: url(http://examplewesbsite.com/logo.png); //Add your logo image path withthis url padding-bottom: 12px; height: auto !important; background-size:130px; width: 100%; } </style> <?php } add_action( 'login_enqueue_scripts', 'custom_admin_login_logo' );

Get custom Taxonomy with empty also in wordpress

<?php $terms = get_terms( array( 'taxonomy' => 'vehicle_type', 'hide_empty' => false, ) ); $count = count( $terms ); if ( $count > 0 ) { echo '<h3>Total Projects: '. $count . '</h3>'; echo '<ul>'; foreach ( $terms as $term ) { echo '<li>' . $term->name . '</li>'; } echo '</ul>'; } ?>OR

$terms = get_terms( 'post_tag', array( 'hide_empty' => false, ) );

Get custom taxonomy link in wordpres

Try below code, i hope it would helpful for you. <?php $args = array('taxonomy' => 'news'); ?> <?php $tax_menu_items = get_categories( $args ); foreach ( $tax_menu_items as $tax_menu_item ):?> <li> <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"> <?php echo $tax_menu_item->name; ?> </a> </li> <?php endforeach; ?> </ul>

Disable plugin update notification in wordpress

Add below code on your current theme's functions.php and add plugin base file name under unset.
function remove_update_notifications( $value ) { if ( isset( $value ) && is_object( $value ) ) { unset( $value->response[ 'hello.php' ] ); unset( $value->response[ 'js_composer/js_composer.php' ] ); } return $value; } add_filter( 'site_transient_update_plugins', 'remove_update_notifications' );

Add custom user filds on admin users panel in Wordpress

Add below code on your current theme's functions.php
add_filter('manage_users_columns', 'add_refer_domain_column'); add_action('manage_users_custom_column','show_refer_domain_columns',10,3); function add_refer_domain_column($columns) { $columns['refer_domain'] = 'Refer'; return $columns; } function show_refer_domain_columns($custom_column,$column_name,$user_id) { if ($column_name=='refer_domain') { $user_info = get_userdata($user_id); $rDomain = $user_info->refer_domain; $custom_column = "\t{$rDomain}\n"; } return $custom_column; }

Shortcode output appearing on top of content in WordPress

The problem is actually very simple. The function executed by shortcode should return the output instead of echoing it.
Example of a shortcode using echo to display output:

function bad_shortcode_function($atts, $content = null) {
    echo '<p>This is the output of shortcode</p>';
}
add_shortcode('bad-shortcode', 'bad_shortcode_function');

The correct way to use shortcodes is to use return. Like this:
function good_shortcode_function($atts, $content = null) {
    $string = '<p>This is the output of shortcode</p>';
    return $string;
}
add_shortcode('good-shortcode', 'good_shortcode_function');  

To view more Visit: https://sabza.org/shortcode-output-appearing-top-post-content-wordpress/

Solved: 404-page not found error in windows hosting

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Set today and tomorrow date in jQuery datepicker

In the change function of the first datepicker, create a date object, set the date one day forward, and set the date of the second datepicker to that date. You can use minDate to make sure any date earlier than the set date can not be picked.
$(function(){ $("#arrival").datepicker({ dateFormat:"dd/mm/yy", changeMonth:true, changeYear:true, numberOfMonths:1, yearRange:":2016", minDate:"dateToday", onClose:function(selectedDate){var myDate = $(this).datepicker('getDate'); myDate.setDate(myDate.getDate()+1); $('#departure').datepicker('setDate', myDate);}}); $("#depart

Redirect automatically after short delay on Error 404 page in wordpress

You should use a client side redirection method to apply the proper delay. If you want to support browsers with disabled JavaScript, just paste a META refresh into a noscript element. It is better to place it inside a noscript element because search engines give a penalty for usual META refresh links. If the redirect is permanent, I suggest you to use the canonical tag too to keep the link-juice of missing pages. Use Below code on 404.php of your current theme<linkrel="canonical"href="https://example.com/"/><noscript><metahttp-equiv="refresh"content="5;URL=https://example.com/"></noscript><!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]--><scripttype="text/javascript">var url ="https://example.com/";var delay ="5000"; window.onload =function(){ setTimeout(GoToURL, delay);}functionGoToURL(){if(typeof IE_fix …

Change bootstrap active tab using jquery

1. Paste this html code
<div id="click-me-div">Click Me</div>

 <ul class="nav nav-tabs">
    <li class="active"><a href="#fruits" data-toggle="tab">I like Fruits</a></li>
    <li><a href="#veggies" data-toggle="tab">I like Veggies Too</a></li>
    <li><a href="#samosas" data-toggle="tab">But Samosa's Rock</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="fruits">Apple, Kiwi, Watermellon</div>
    <div class="tab-pane" id="veggies">Kale, Spinach, Pepper</div>
    <div class="tab-pane" id="samosas">Awesome, Spine Tingling, Explosive</div>
</div>

2. Add below jquery
<script type="text/javascript">
$(document).ready(function() {
    $("#c…

Remove Script & Stylesheet Versions in Wordpress

put below code in your themes function.php

add_filter( 'script_loader_src', 'remove_version' );
add_filter( 'style_loader_src', 'remove_version' );
function remove_version ( $src ) {
  global $wp_version;
  $version_str = '?ver='.$wp_version;
  $version_str_offset = strlen( $src ) - strlen( $version_str );
  if( substr( $src, $version_str_offset ) == $version_str )
    return substr( $src, 0, $version_str_offset );
  else
    return $src;
}

Change the height of the Revolution Slider in wordpress

Please add this code in Customize -> Custom -> CSS:

.rev_slider_wrapper, .rev_slider, .tp-fullwidth-forcer, .rev_slider .tp-bgimg.defaultimg {
    max-height: 400px !important;

}

Hope it helps.

Get category id for category.php page in wordpress

You can simply use: $cur_cat_id = get_cat_id( single_cat_title("",false) );

Get post data by id using AJAX in wordpress

Add below code on your theme's function.php

add_action('wp_ajax_nopriv_ajax_request','ajax_handle_request'); add_action('wp_ajax_ajax_request','ajax_handle_request');function ajax_handle_request(){ $postID = $_POST['id'];if(isset($_POST['id'])){ $post_id = $_POST['id'];}else{ $post_id ="";}global $post; $post = get_post($postID); $response = array('sucess'=>true,'post'=> $post,'id'=> $postID

Featured image option not displaying in wordpress admin panel

Add this code to the functions.php file of your theme: // This theme uses post thumbnails add_theme_support('post-thumbnails');If you getting this type of issue again please goto wp-admin->add new post-> screen options. At the top of your page you see this screen option open it and check the value featured image if not checked. Now you see the option of featured image in your post page admin side.

get selected radio button value using jQuery

To get the value of the selectedradioName item of a form with id myForm:

$('input[name=radioName]:checked','#myForm').val()Here's an example:$('#myForm input').on('change',function(){ alert($('input[name=radioName]:checked','#myForm').val());});<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Redirect page using jQuery

You can use following methods to redirect a page using jQuery
window.location.replace("http://www.keredari.com");window.location.href = "http://stackoverflow.com";$(location).attr('href', 'http://www.keredari.com');$(window).attr("location","http://www.keredari.com");

Setup WordPress Permalinks on Windows IIS

Create a file web.config under root folder where WordPress has installed and past following code. or download from Github.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

</configuration>

Redirect to requested page after login in wordpress

Add below code in function.php of your theme.
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( 'administrator', $user->roles ) ) {
// redirect them to the default place
return $redirect_to;
} else {
return $request;
}
} else {
return $request;
}
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

Get value If radio button is checked using jquery

$('input:radio[name="linkTpye"]').change(function(){if($(this).is(':checked'