Skip to content

Instantly share code, notes, and snippets.

@CEscorcio
CEscorcio / get_slug()
Created August 1, 2013 11:59
/************* Display the page or post slug *****************/ Just use get_slug() Use this in Functions.php
/************* Display the page or post slug *****************/
function get_the_slug( $id=null ){
if( empty($id) ):
global $post;
if( empty($post) )
return ''; // No global $post var available.
$id = $post->ID;
endif;
$slug = basename( get_permalink($id) );
@CEscorcio
CEscorcio / rewrite
Created July 26, 2013 12:36
wp-content/uploads/.htaccess # Attempt to load files from production if they're not in our local version
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Replace http://stevegrunwell.com with your production site's domain name
RewriteRule (.*) http://stevegrunwell.com/wp-content/uploads/$1
</IfModule>
@CEscorcio
CEscorcio / tabs
Created July 25, 2013 15:05
Tabs in bootstrap framework
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#pane1" data-toggle="tab">Tab 1</a></li>
<li><a href="#pane2" data-toggle="tab">Tab 2</a></li>
<li><a href="#pane3" data-toggle="tab">Tab 3</a></li>
<li><a href="#pane4" data-toggle="tab">Tab 4</a></li>
</ul>
<div class="tab-content">
<div id="pane1" class="tab-pane active">
<h4>The Markup</h4>
@CEscorcio
CEscorcio / post == title page
Created July 18, 2013 14:18
lists posts from a category that has the same name as the page.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: endif; ?>
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php the_content(); ?>
<?php endwhile; else: endif; ?>
@CEscorcio
CEscorcio / exclude cat
Created July 9, 2013 17:11
Exlude category from loop
<?php
$args=array(
'category__not_in' => array(8),
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 5,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
@CEscorcio
CEscorcio / wordpress
Created June 26, 2013 19:35
last 3 posts with thumb
<ul>
<?php $the_query = new WP_Query( 'showposts=3' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<li><?php the_excerpt(__('(more…)')); ?></li>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail( array(100,100) );
} ?>
<?php endwhile;?>
</ul>
@CEscorcio
CEscorcio / deploy
Created June 25, 2013 08:15
deploy to bitbucket
<?php
// Set these dependant on your BB credentials
$username = 'username';
$password = 'password';
$branch = 'master';
// FTP Credentials
@CEscorcio
CEscorcio / Featured Posts
Created June 17, 2013 18:15
Featured posts in Wordpress *** cat1= category that will echo
@CEscorcio
CEscorcio / excerpt
Created June 17, 2013 16:52
Limit excerpt and change read more text
functions.php
function get_excerpt($count){
$permalink = get_permalink($post->ID);
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = '<p>'.$excerpt.'... </br><a href="'.$permalink.'">Read more more</a></p>';
return $excerpt;
@CEscorcio
CEscorcio / latest
Created June 17, 2013 15:32
get latest posts
<ul>
<?php $the_query = new WP_Query( 'showposts=5' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<span class="latestpostmeta"><?php the_time('M jS, Y') ?> </span></li>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<li><?php the_excerpt(__('(more…)')); ?></li>
<?php the_post_thumbnail(); ?>
<?php endwhile;?>
</ul>