IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » depi's snipts The latest snipts from depi.

showing 1-19 of 19 snipts
  • Modify the_excerpt() output
    <?php
    function my_excerpt_length($text){
    	return 10;
    }
    add_filter('excerpt_length', 'my_excerpt_length');
    
    function new_excerpt_more($more) {
    	return '...';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Aug 14, 2010 at 12:57 p.m. EDT
  • Number of posts in a loop
    <?php $number_of_posts = $wp_query->post_count; ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Jul 29, 2010 at 7:07 a.m. EDT
  • Returns the number of results
    <?php echo $wp_query->found_posts; ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Mar 02, 2010 at 4:13 p.m. EST
  • Returns the searched keyword
    <?php echo get_search_query(); ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Mar 02, 2010 at 4:10 p.m. EST
  • Return a class is a certain page template is used
    <?php
    function page_template_class() {
    	$page_template_class = '';
    	
    	if (is_page_template('kinderen.php')) {
    		$page_template_class = 'kinderen';
    	}
    	
    	if (!empty($page_template_class)) {
    		echo ' class="'.$page_template_class.'"';
    	}
    	else {
    		return false;
    	}
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Feb 20, 2010 at 1:33 p.m. EST
  • Replace the output of wp_list_pages();
    <?php
    $page_output = wp_list_pages('echo=0&title_li=&sort_column=menu_order&depth=1&include='.$page_ids);
    $page_output = preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', $page_output);
    echo $page_output;
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Feb 04, 2010 at 12:31 p.m. EST
  • Get the nth sentence from the post (beta)
    <?php
    function the_nth_sentence($sentence_num = 1) {
    	if ($sentence_num == 0) {
    		return false;
    	}
    	if ($sentence_num >= 1) {
    		$sentence_num = $sentence_num-1;
    	}
    	$content = get_the_content('',FALSE,'');
    	$content = apply_filters('the_content', $content);
    	$content = strip_tags($content);
    	$pos = strpos($content, '.');
    	for($i=1; $i<=$sentence_num; $i++) {
    		$pos = strpos($content, '.', $pos+1);
    	}
    	echo '<p>' . substr($content,0,$pos+1) . '</p>';
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Feb 03, 2010 at 1:55 p.m. EST
  • Get the first sentence of the post
    <?php
    function the_first_sentence() {
    	$content = get_the_content('',FALSE,'');
    	$content = apply_filters('the_content', $content);
    	$content = strip_tags($content);
    	$pos = strpos($content, '.');
    	echo '<p>' . substr($content,0,$pos+1) . '</p>';
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Feb 03, 2010 at 12:21 p.m. EST
  • Exclude array of categories
    <?php
    function exclude_categories(array $categories, $sign = TRUE) {
    	$exclude_cat = new WP_Query('showposts=0');
    	if ($sign == TRUE):
    		$sign = "-";
    	else:
    		$sign = "";
    	endif;
    
    	foreach((get_categories()) as $cat):
    		if(in_array($cat->cat_name, $categories)):
    			$exclude_id .= $sign . $cat->cat_ID .',';
    		endif;
    	endforeach;
    	$exclude_id = substr($exclude_id, 0, -1);
    	return $exclude_id;
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Nov 16, 2009 at 8:07 a.m. EST
  • Display only "sticky posts"
    <?php $sticky = new WP_Query(array("post__in" =>get_option("sticky_posts"))); ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Nov 16, 2009 at 7:28 a.m. EST
  • Get permalink to a page by id
    <?php echo get_permalink(get_page_id('articles')); ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Nov 15, 2009 at 9:09 a.m. EST
  • Get the slug of the current post/page
    <?php
    echo $post->post_name;
    // the $post array also contains other useful/interesting data
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Jul 27, 2009 at 11:34 a.m. EDT
  • Alternative replacement for the_content(); - it show a first <p> from a post (place in functions.php)
    <?php
    function the_summary() {
    	$content = get_the_content('',FALSE,'');
    	$content = apply_filters('the_content', $content);
    	$pos = strpos($content, '</p>');
    	echo substr($content,0,$pos+4);
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on Jun 26, 2009 at 5:37 a.m. EDT
  • Get category ID
    <?php
    get_cat_id('categoryName');
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:26 a.m. EDT
  • Get $post_category_id
    <?php
    foreach(get_the_category() as $category) {
      $post_category_id = $category->cat_ID;
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:25 a.m. EDT
  • getTopParentPostTitle
    <?php
    function getTopParentPostTitle($myid){
    	$mypage = get_page($myid);
    
    	if ($mypage->post_parent == 0){
    		return $mypage->post_title;
    	}
    	else{
    		return getTopParentPostName($mypage->post_parent);
    	}
    
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:24 a.m. EDT
  • getTopParentPostName
    <?php
    function getTopParentPostName($myid){
    	$mypage = get_page($myid);
    
    	if ($mypage->post_parent == 0){
    		return $mypage->post_name;
    	}
    	else{
    		return getTopParentPostName($mypage->post_parent);
    	}
    
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:22 a.m. EDT
  • Yahoo CSS Reset
    /* YUI CSS RESET */
    body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin:0; padding:0; }
    table { border-collapse:collapse; border-spacing:0; }
    fieldset,img { border:0; }
    address,caption,cite,code,dfn,em,strong,th,var { font-style:normal; font-weight:normal; }
    ol,ul {	list-style:none; }
    caption,th { text-align:left; }
    h1,h2,h3,h4,h5,h6 { font-size:100%; font-weight:normal; }
    q:before,q:after { content:''; }
    abbr,acronym { border:0; }
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:21 a.m. EDT
  • get_page_id
    <?php
    function get_page_id($page_name){
    	global $wpdb;
    	$page_name = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."' AND post_status = 'publish' AND post_type = 'page'");
    	return $page_name;
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by depi on May 09, 2009 at 6:18 a.m. EDT
Sign up to create your own snipts, or login.