Disable Plugin Updates
The snippet below will allow you to disable plugin updates.
1 2 3 4 |
<?php remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); ?> |
List all categories with posts
The snippet below will let you list all categories with posts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?php //for each category, show all posts $cat_args=array( 'orderby' => 'name', 'order' => 'ASC' ); $categories=get_categories($cat_args); foreach($categories as $category) { $args=array( 'showposts' => -1, 'category__in' => array($category->term_id), 'caller_get_posts'=>1 ); $posts=get_posts($args); if ($posts) { echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> '; foreach($posts as $post) { setup_postdata($post); ?> <p><a href=" <?php the_permalink() ?> " rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?> "> <?php the_title(); ?> </a></p> <?php } // foreach($posts } // if ($posts } // foreach($categories ?> |
Override WordPress and Site URL
The following snippet will let you override WordPress and site URL.
1 2 3 4 5 |
<?php // Define wp home and site url define('WP_HOME','http://production.whateversite.com'); define('WP_SITEURL','http://production.whateversite.com'); ?> |
Get the first link in post
The following snippet will let you get the first link in post.
1 2 3 4 5 6 7 8 9 10 11 |
function get_content_link( $content = false, $echo = false ) { if ( $content === false ) $content = get_the_content(); $content = preg_match_all( '/hrefs*=s*["']([^"']+)/', $content, $links ); $content = $links[1][0]; if ( empty($content) ) { $content = false; } return $content; } |
Check if sidebar has widgets
The snippets checks that if a sidebar of your website having any widget areas in it or not.
1 2 3 4 5 6 7 |
function is_sidebar_active($index) { global $wp_registered_sidebars; $widgetcolums = wp_get_sidebars_widgets(); if ($widgetcolums[$index]) return true; return false; } |