Enqueue Jquery

This is how to enqueue jquery and several other scripts that depend on jQuery. Paste the following into your functions.php file: /** * Add jQuery */ function add_jquery_script() { wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js’); wp_enqueue_script( ‘jquery’ ); } add_action(‘wp_enqueue_scripts’, ‘add_jquery_script’); function my_scripts_method() { wp_enqueue_script( ‘custom-script’, get_template_directory_uri() . ‘/js/theme.script.js’, array( ‘jquery’ ) ); wp_enqueue_script( ‘jquery-easing’, Read More…

WP_http(); SSL

WordPress verifies the  SSL cert when you use  $request = new WP_Http(); Sometimes it throws an error because it doesn’t recognize the SSL. To fix it add this code to the functions.php file. add_filter(‘https_ssl_verify’, ‘__return_false’);

Redirect to Homepage Snippet

//redirect admins to the dashboard and other users to the homepage function my_login_redirect( $redirect_to, $request, $user ){ //is there a user to check? if( is_array( $user->roles ) ) { //check for admins if( in_array( “administrator”, $user->roles ) ) { // redirect them to the default place return home_url( ‘/wp-admin/’ ); } else { return home_url(); Read More…

Custom Logo wordpress Login Snippet

//custom login code AND hide register link function custom_login_logo() { echo ‘<style type=”text/css”>h1 a { background: url(‘.get_bloginfo(‘template_directory’).’/images/logo.png) 50% 50% no-repeat !important; height:100px !important; } body.login div#login p#nav {display:none; visibility:hidden !important;} #backtoblog{float:left; .password{float:left; margin:15px !important}</style>’; } add_action(‘login_head’, ‘custom_login_logo’); function my_login_title() { return get_option(‘blogname’); } add_filter(‘login_headertitle’, ‘my_login_title’); function custom_redirect_link() { echo ‘<p><a class=”password” href=’; echo wp_lostpassword_url(); echo Read More…

Get Category Post ID

This will help get and display the 1st category ID of the current post   $categories = get_the_category(); //get all categories for this post echo ‘first category is ‘ . $categories[0]->cat_ID;

Custom Excerpt Snippet

You can use this code in your functions.php file to change the excerpt length and also the ‘more’ tag. // Replaces the excerpt “more” text by a link function new_excerpt_more($more) { global $post; if (is_category( ’21’ )){ return ‘ View Image Gallery‘; } else { return ‘ Read the full article…‘; } } add_filter(‘excerpt_more’, ‘new_excerpt_more’); Read More…

Password Protected Page

Add this code outside the loop on the template page to enable password protection. <!–password protect code –> <?php if ( ! post_password_required( $post ) ) { ?> <!–password protect code –> CONTENT LOOP <!– end of the password protect –> <?php } else { echo get_the_password_form(); } ?> <!– end of the password protect Read More…