Posts Tagged ‘snippets’

Nice drush theme commando’s

theme-enable        => pm-enable theme-disable       => pm-disable (it’s possible to just use: drush en/dis THEMENAME) theme-info          => pm-info theme-list          => pm-list –type=theme theme-list-enabled  => pm-list –type=theme –status=enabled theme-set-default   => vset theme_default theme-set-admin     => vset admin_theme theme-status        => status theme Have fun!


Splitting nextgen gallery form the_content

Want to show the nextgen gallery somewhere else than the rest of the content? Add this to your functions.php // shows the content echo ngg_content_split(“content”); // shows the gallery echo ngg_content_split(“gallery”) function ngg_content_split($get=”content”){ //get the post content $content_data = get_the_content(); //extract shortcode from content preg_match(“/\[ngg([^}]*)\]/”, $content_data ,$matches); $results = $matches[1]; //if shortcode exists in content if (!empty($results) [...]


get the current category from permalink structure

If a post has different categories it seems to be hard to get the chosen category…. The solution: $currentCat= get_query_var(“cat”); $allCats=  get_the_category(); foreach ($allCats as $cat){ if ($cat->cat_ID ==$currentCat){ $currentCat=$cat; continue; } } now you have the current category object…


UPDATE:function to extract image as thumbnail from a post

This method is depreciated in favor of the wordpress 2.9 thumbnail functionality.   Here is a good tutorial how to implement it. When you want to add an image to your lists of posts you can use this function (paste it into functions.php): function postimage($size=medium) { if ( $images = get_children(array( ‘post_parent’ => get_the_ID(), ‘post_type’ [...]


Command line snippet to create a tar.gz and backup a database

backup whole directory tar -pvczf backup.tar.gz directory dump databse mysqldump -u database_user -p database > backup.sql


wordpress

Using multiple domains for one wordpress installation (portal site)

If you have portal site with different sections and different URL’s you van rewrite the url with either Apache rewrites (which is like black magic to me) or less nice php’s header location. If you need a high performance solution you have to deal with Apache’s rewrite if you only need a short hack try the following solution…


equal heights of div’s using jquery

First check if jquery is loaded. If using wordpress  you can look  in the header.php for the function call of wp_head(). Add following line <?php wp_enqueue_script("jquery"); ?> <?php wp_head(); ?> If you are sure that jquery is loaded add the following code <script type="text/javascript"> var $j = jQuery.noConflict(); function equalHeight(group) { tallest = 0; group.each(function() [...]