Skip to content

Instantly share code, notes, and snippets.

@reinislejnieks
Created June 7, 2012 20:08
Show Gist options
  • Save reinislejnieks/2891269 to your computer and use it in GitHub Desktop.
Save reinislejnieks/2891269 to your computer and use it in GitHub Desktop.
useful WP things
<?php
wp_enqueue_script('jquery'); /*in header.php before wp_head();*/
/*--------------------------------*/
/* for wp */
wp_deregister_script('jquery');
wp_register_script('jquery',("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"),false,'1.6.2');
wp_enqueue_script('jquery');
/*--------------------------------*/
bloginfo('template_directory');
/*--------------------------------*/
if():
else if():
else:
endif;
/*--------------------------------*/
echo $var = get_the_title($post->post_parent);/*get parent page title*/
/*--------------------------------*/
echo $post->ID;/*get page ID*/
/*--------------------------------*/
include (TEMPLATEPATH . '/altheader.php');
/*--------------------------------*/
the_date('y-m-d','<p>','</p>');
/*--------------------------------*/
is_sticky(); is_home();
/*--------------------------------*/
//to do stuff outside of the main loop
$my_new_query = new WP_Query();
//and then
if($my_new_query->have_posts()){
while($my_new_query->have_posts()){
$my_new_query->the_post();
}
}
/*--------------------------------*/
/* Template Name: My Page Template */
/*--------------------------------*/
add_action('action_hook','your_function');
/*--------------------------------*/
// CUSTOM ADMIN LOGIN HEADER LOGO
function my_custom_login_logo() {
echo '<style type="text/css"> h1 a { background-image:url('.get_bloginfo('template_directory').'/images/logo_admin.png) !important; } </style>';
}
add_action('login_head', 'my_custom_login_logo');
/*--------------------------------*/
// Manually add sharebuttons
add_filter( 'the_content', 'ilc_share' );
function ilc_share( $content ) {
global $post;
$postlink = get_permalink($post->ID);
$posttitle = get_the_title($post->ID);
$html = '<ul class="share-entry">';
// Twitter
$html .= '<li><a class="share-twitter" title="Share on Twitter" rel="external" href="http://twitter.com/share?text='.$posttitle.'&url='.$postlink.'">Share on Twitter</a></li>';
// Facebook
$html .= '<li><a class="share-facebook" title="Share on Facebook" rel="external" href="http://www.facebook.com/share.php?u=' . $postlink . '">Share on Facebook</a></li>';
// LinkedIn
$html .= '<li><a class="share-linkedin" title="Share on LinkedIn" rel="external" href="http://www.linkedin.com/shareArticle?mini=true&url=' . $postlink . '&title=' . $posttitle . '">Share on LinkedIn</a></li>';
// Digg
$html .= '<li><a class="share-digg" title="Share on Digg" rel="external" href="http://digg.com/submit?url=' . $postlink . '">Share on Digg</a></li>';
// StumbleUpon
$html .= '<li><a class="share-stumbleupon" title="Share on StumbleUpon" rel="external" href="http://www.stumbleupon.com/submit?url=' . $postlink . '&title=' . $posttitle . '">Share on StumbleUpon</a></li>';
// Google+
$html .= '<li><a class="share-googleplus" title="Share on Google+" rel="external" href="https://plusone.google.com/_/+1/confirm?url=' . $postlink . '">Share on Google+</a></li>';
$html .= '</ul>';
return $content . $html;
}
/*--------------------------------*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment