delete_option('thesis_design_options');
delete_option('thesis_options');
Tag Archive for wordpress
Reset Thesis
Manually load (Google’s) Latest jQuery in WordPress
<?php wp_deregister_script('jquery'); ?>
<?php wp_head(); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
WordPress Get Category Slug
if(is_category()) {
$cat = get_query_var('cat');
$yourcat = get_category($cat);
echo "the slug is" . $yourcat->slug;
}
Date Based Category Archives for WordPress
function extend_date_archives_flush_rewrite_rules(){
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
add_action('init', 'extend_date_archives_flush_rewrite_rules');
function extend_date_archives_add_rewrite_rules($wp_rewrite){
$rules = array();
$structures = array(
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
);
foreach( $structures as $s ){
$rules += $wp_rewrite->generate_rewrite_rules($s);
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');
WordPress, Basic conditional form
<?php
if ( in_category('11') ) {
include (TEMPLATEPATH . '/navigation.php'); }
else {
echo "Something else"; }
?>
Call Custom Field Values (WordPress)
<?php $customField = get_post_custom_values("page_blurb");
if (isset($customField[0])) {
echo $customField[0];
}
?>
My general wordpress code
<!--Reference the theme directory -->
<?php bloginfo('template_directory'); ?>
<!--php language attributes -->
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<!--Page template code -->
<?php /* Template Name: Home */ ?>
<!--Home link -->
<a href="<?php bloginfo('url'); ?>/" title="Return To Home Page » <?php bloginfo('name'); ?>" tabindex="1">
<!--Include the search form -->
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
<!--Search form with no search button -->
<?php $search_text = "Search"; ?>
<form method="get" id="searchform"
action="<?php bloginfo('home'); ?>/">
<input type="text" value="<?php echo $search_text; ?>"
name="s" id="s"
onblur="if (this.value == '')
{this.value = '<?php echo $search_text; ?>';}"
onfocus="if (this.value == '<?php echo $search_text; ?>')
{this.value = '';}" />
<input type="hidden" id="searchsubmit" />
</form>
<!--RSS feeds -->
<?php bloginfo('rss2_url'); ?>
Also see: <a href="http://codex.wordpress.org/WordPress_Feeds" >http://codex.wordpress.org/WordPress_Feeds</a>
<!--List pages -->
<?php wp_list_pages('title_li=&depth=0'); ?>
My additional CSS markup as standard for wordpress
/* Default spacing for items floating left or right */
img.alignleft {margin:10px 10px 10px 0;}
img.alignright {margin:10px 0px 10px 10;}
.clear {clear:both;}
img {border:solid 1px #ccc}
Required CSS for wordpress
.aligncenter,
div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
.alignleft {
float: left;
}
.alignright {
float: right;
}
.wp-caption {
border: 1px solid #ddd;
text-align: center;
background-color: #f3f3f3;
padding-top: 4px;
margin: 10px;
/* optional rounded corners for browsers that support it */
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.wp-caption img {
margin: 0;
padding: 0;
border: 0 none;
}
.wp-caption p.wp-caption-text {
font-size: 11px;
line-height: 17px;
padding: 0 4px 5px;
margin: 0;
}
.categories {...}
.cat-item {...}
.current-cat {...}
.current-cat-parent {...}
.pagenav {...}
.page_item {...}
.current_page_item {...}
.current_page_parent {...}
.widget {...}
.widget_text {...}
.blogroll {...}
.linkcat{...}
WordPress query to pull a snippet from a post/page
<?php query_posts('pagename=about'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div><h4>Type your title here</h4>
<p><?php echo substr(strip_tags($post->post_content), 0, 165); ?>... <a href="<?php bloginfo('url'); ?>/about">Read More</a></p></div>
<?php endwhile; endif;
//Reset Query
wp_reset_query();
?>