Custom WordPress Redirect on Login Fail

I use this snippet to change the default redirect to /wp-login when user authentication fails on attempted login.   //redirects user to the page the login form is on and adds ?login=failed to the url add_action( ‘wp_login_failed’, ‘my_front_end_login_fail’ ); // hook failed login //redirect on login fail (doesn’t work when user clicks empty form. The Read More…

Get newest post url

You can use this to the the url of the most recent post. <?php //list post title for one post is specified category $cat = 1; //category ID $args=array( ‘category__in’ => array($cat), ‘showposts’=>1, ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link Read More…

WordPress Comments

If you want to modify how the comments # is displayed you can use this code: <?php if ( comments_open() ) : ?> <span class=”post-comment”><?php comments_popup_link( __( ‘Comments <span>0</span>’, ‘base’ ), __( ‘Comments <span>1</span>’, ‘base’ ), __( ‘Comments <span>%</span>’, ‘base’ ) ); ?></span> <?php endif; //post comment ?> As you can see you can add Read More…

Get Sub category ID’s of a post

You can use this code to get the subcategory ID’s of a post. <?php      $categories = get_the_category();      $this_cat_ID = $categories[0]->cat_ID;      $this_cat_name = $categories[0]->cat_name;      $this_cat_url = get_category_link($this_cat_ID);      // get the sub category if we have them      foreach ($categories as $cat) {         $parent Read More…

Detect all Browser types PHP

You can use this snippet to detect browser types in PHP and do what you want with them. You might have to moved everything outside of the function to get it to work sometimes. //get browser info function get_user_browser() { $u_agent = $_SERVER[‘HTTP_USER_AGENT’]; $ub = ”; if(preg_match(‘/MSIE/i’,$u_agent)) { $ub = “ie”; } elseif(preg_match(‘/Firefox/i’,$u_agent)) { $ub Read More…