To add the custom background functionality in the Theme Customizer use this code. /** * Setup the WordPress core custom background feature. * * Use add_theme_support to register support for WordPress 3.4+ * as well as provide backward compatibility for WordPress 3.3 * using feature detection of wp_get_theme() which was introduced * in WordPress 3.4. Read More…
This is the code for the top level parent page //Get the top level parent page id function get_top_parent_page_id() { global $post; $ancestors = $post->ancestors; // Check if page is a child page (any level) if ($ancestors) { // Grab the ID of top-level page from the tree return end($ancestors); } else { // Page Read More…
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…
You can use this to access the the WordPress posts. //Reading posts for “Events” category; $posts = get_posts(“category=” . get_cat_ID(“Events”) .’&orderby=date&order=ASC&numberposts=50′); Then you can create an array and access the post data like this. //Creating drop down item array. $items = array(); //Adding initial blank value, for a dropdown, or just to Read More…
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…
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…
You can get the # of attachments related to a post by using this snippet. <?php $attachments = get_children(array(‘post_parent’=>$post->ID)); $nbImg = count($attachments); echo ‘There are ‘.$nbImg.’ pictures on this 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…
I ended up creating a simple plugin based on this tutorial: http://wp.smashingmagazine.com/2011/10/25/create-perfect-emails-wordpress-website/ Plus I had to create a page template for the password reset based on these 2 tutorials: http://www.sutanaryan.com/wordpress/how-to-create-custom-reset-or-forget-password-in-wordpress/ http://www.tutorialized.com/tutorial/Create-a-Wordpress-Custom-Password-Reset-Page-Template/76026
I used this code to validate a specific unique code that you have to fill out in order to register on the taxlientrainer.com website. // UNIQUE code validation. Checks to see if a valid promo code was entered // 1 – Tie our validation function to the ‘gform_validation’ hook add_filter(‘gform_validation_3’, ‘validate_code’); function validate_code($validation_result) { Read More…