Sunday, February 26, 2017

Change Thumbnail Position in WordPress

// Changing featured image placement in custom post type

add_action('do_meta_boxes', 'customposttype_image_box');

function customposttype_image_box() {



 remove_meta_box( 'postimagediv', 'customposttype', 'side' );



 add_meta_box('postimagediv', __('Custom Image'), 'post_thumbnail_meta_box', 'partner', 'normal', 'high');



}

Tuesday, February 7, 2017

How to Make Parent Menu Clickable in Bootstrap Navwalker Menu

For me it worked this way: I assume you make usage of the wp-bootstrap-navwalker
Open up the wp-bootstrap-navwalker.php with your editor and look up for line approx. 83
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
   $atts['href']        = '#';
   $atts['data-toggle'] = 'dropdown';
   $atts['class']           = 'dropdown-toggle';
} else {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
}
Change this piece of code to:
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
   //$atts['data-toggle']   = 'dropdown';
   $atts['class']           = 'dropdown-toggle';
} else {
   $atts['href'] = ! empty( $item->url ) ? $item->url : '';
}
Note: $att['href'] is enabled now, the the $atts['data-toggle'] is disabled which makes the parent link clickable.
Now open up your style.css and add this piece of code to activate the hover function for your WordPress menu with dropdown and clickable parent.
.dropdown:hover .dropdown-menu {
    display: block;
}
Note: The behaviour of the menu will change slightly on small devices with small screens. No additional jQuery required.

Monday, February 6, 2017

How To Check Server Directory Path

Create a server.php file and upload inside your root directory. Insert the below code and enter url on your website. yourwebsite.com/server.php

<?php
echo dirname(__FILE__);

Sunday, January 29, 2017

Make an Anchor Link non-clickable or disabled using jQuery?

<a id="nclick" href="#">

jQuery('#nclick').click(function(e)
{
    e.preventDefault();
});

Friday, January 27, 2017

Lists all the Posts from Current Taxonomy

<?php $term = $wp_query->queried_object;
   $getterm = $term->slug;
?>
<?php $args = array(
    'post_type' => 'product',
  'tax_query' => array(
      array(
          'taxonomy' => 'product_category',
          'terms' => $getterm,
          'field' => 'slug',
      )
  ),
    );
$product_latest = new WP_Query( $args ); ?>
<?php while( $product_latest->have_posts() ): $product_latest->the_post(); ?>
 // Your content goes here
<?php endwhile; ?>

Thursday, January 26, 2017

Wordpress- hook to auto login after registration

function _new_user_auto_log_in($user_id){ if(!is_user_logged_in()){ $secure_cookie = is_ssl(); $secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, array()); global $auth_secure_cookie; $auth_secure_cookie = $secure_cookie; wp_set_auth_cookie($user_id, true, $secure_cookie); $user_info = get_userdata($user_id); do_action('wp_login', $user_info->user_login, $user_info); } } add_action('user_register', '_new_user_auto_log_in');

Replace Default WordPress Logo in the Login Dashboard Page

function custom_loginlogo() {
echo '';
}
add_action('login_head', 'custom_loginlogo');
add_filter( 'login_headerurl', 'custom_loginlogo_url' );
function custom_loginlogo_url($url) {
    return 'http://www.your-site-url.com';
}