WordPress has a built-in display categories widget that can show as a list or a dropdown. However, it only shows categories with posts attached to them. If you want to show all categories in a dropdown use this code. <form action=”<?php bloginfo(‘url’); ?>/” method=”get”> <?php $select = wp_dropdown_categories(‘show_option_none=Select State&show_count=1&orderby=name&echo=0&selected=0&hide_empty=0’); $select = preg_replace(“#<select([^>]*)>#”, “<select$1 onchange=’return this.form.submit()’>”, Read More…
Trying to figure out how to get event tracking working with the new async (analytics.js) code was a pain. Googles documentation for anything to do with analytics is always confusing. <script> (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’); ga(‘create’, ‘UA-XXX-X’, ‘example.com’); ga(‘send’, ‘pageview’); //here is the code that actually worked. You put it in the script area Read More…
This is some code that will help you to customize the password protected form. // change password protected text function my_password_form() { global $post; $label = ‘pwbox-‘.( empty( $post->ID ) ? rand() : $post->ID ); $o = __( “<p>In preparation for the Buying Summit we recommend you watch this incredible training from Matt Larson. Read More…
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…
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…
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…