Category: PHP

How to put inline javascript in the footer of your page with WordPress

You can do this by adding this code to your template file. This will add a hook. Your javascript code will now be placed in the footer of your page (or where the wp_footer() function is called). <?php function footer_script(){ ?> <script> jQuery(document).ready(function(){ //put your js code here }) </script> <?php } add_action('wp_footer', 'footer_script'); ?> … Continue reading How to put inline javascript in the footer of your page with WordPress

Tabindex problems with Gravity forms in WordPress

Sometimes there are problems with the tabindex when you use the Gravity forms plugin in WordPress. You can fix this by adding this to your theme's functions.php file //############################################################################### // Fix Gravity Form Tabindex Conflicts //############################################################################### add_filter("gform_tabindex", "gform_tabindexer"); function gform_tabindexer() { $starting_index = 1000; // if you need a higher tabindex, update this number return … Continue reading Tabindex problems with Gravity forms in WordPress

Change the amount of tags in tagcloud in WordPress

Add this piece of code to your theme's function.php file. add_filter('widget_tag_cloud_args','set_number_tags'); function set_number_tags($args) { $args = array('number' => 20); return $args; }  Set the number of the amount of tags you want to display on your page. Or you can just use the parameters for the wp_tag_cloud function. <?php $args = array( 'smallest' => 8, 'largest' … Continue reading Change the amount of tags in tagcloud in WordPress

How to make a custom protected page in WordPress

The default password form uses this message: "This post is password protected. To view it please enter your password below:". You can use a custom text to display on a protected page by using a filter in WordPress. Add this code to your theme's functions.php file: <?php function custom_password_form() { global $post; $label = 'protected-page-'.( … Continue reading How to make a custom protected page in WordPress

Get the depth of the current page in WordPress

If you want to get the level of the current page in WordPress you can use this  // gets the depth of the current page global $wp_query; $object = $wp_query->get_queried_object(); $parent_id = $object->post_parent; $depth = 0; while ($parent_id > 0) { $page = get_page($parent_id); $parent_id = $page->post_parent; $depth++; } echo $depth;  This function will echo … Continue reading Get the depth of the current page in WordPress

Remove SEO title, keywords, description columns from the post and pages list when using the all-in-one-seo-pack WordPress plugin

Remove SEO title, keywords, description columns from the post and pages list when using the all-in-one-seo-pack WordPress plugin

I always use the all-in-one-seo-pack for WordPress websites which is a great plugin for SEO purposes. The only drawback is that it screws up the list of pages or posts in your WordPress admin section by adding three extra colums to it (SEO title, SEO keywords, SEO description). To remove these colums go to the … Continue reading Remove SEO title, keywords, description columns from the post and pages list when using the all-in-one-seo-pack WordPress plugin