<?php
//Enqueue Javascript
function init_my_script() {
wp_enqueue_script('my_script','/file_location_here/my_script.js');
}
add_action('init', init_my_script');
?>
<?php
//Enqueue Javascript
function init_my_script() {
wp_enqueue_script('my_script','/file_location_here/my_script.js');
}
add_action('init', init_my_script');
?>
<?php echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?>
//Dynamic CSS
function quantum_css(){
wp_enqueue_style('dynamic-css',bloginfo('stylesheet_url') . '/admin/color_picker/picker.css');
wp_print_styles();
}
add_action('wp_enqueue_styles','quantum_css');
<?php
//Check for a hex color string '#c1c2b4'
if(preg_match('/^#[a-f0-9]{6}$/i', $color)) //hex color is valid
{
//Verified hex color
}
//Check for a hex color string without hash 'c1c2b4'
else if(preg_match('/^[a-f0-9]{6}$/i', $color)) //hex color is valid
{
$fix_color = '#' . $color;
}
?>
//Exlude cats from the_category()
function incomplete_cat_list($separator) {
$first_time = 1;
foreach((get_the_category()) as $category) {
if ($category->cat_name != 'ExcludeCat1' && $category->cat_name != 'ExcludeCat2') {
if ($first_time == 1) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
$first_time = 0;
} else {
echo $separator . '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
}
}
}
}
//Add the above code to functions.php
//Use this to call the function <?php incomplete_cat_list(', '); ?>
$this_page_id = get_query_var('page_id');
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$post->ID
<?php
//Category ID ~ Name List
function hyper_id_name_widget_function() {
$categories=get_categories('orderby=id');
foreach($categories as $category) {
echo '<p>Cat ' . get_cat_ID($category->name) . ' = <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p>';
}
}
function hyper_id_name_widget() {
wp_add_dashboard_widget('hyper_id_name_widget', 'Category ID ~ Name List', 'hyper_id_name_widget_function');
}
add_action('wp_dashboard_setup', 'hyper_id_name_widget' );
?>
//add this to the functions.php file
add_theme_support( 'post-thumbnails' );
//add this to the functions.php file this to only add to page templates not posts
add_theme_support( 'post-thumbnails', array( 'page' ) );
//Show the thumbnail
<?php the_post_thumbnail( 'thumbnail' ); ?>
//Show the thumbnail as medium
<?php the_post_thumbnail( 'medium' ); ?>
//Change thumbnail size
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'game-thumb', 100, 74 ,true);//true arg is for hard crop
}
//Use a conditional
<?php if ( has_post_thumbnail() ) the_post_thumbnail('game-thumb'); ?>
//Change the title attribute
<?php the_post_thumbnail( 'post-thumbnail', array( 'title' => $title, 'alt' => $title ) ); ?>
<?php
foreach((get_the_category()) as $childcat) {
$parentcat = $childcat->category_parent;
$the_cat_name = get_cat_name($parentcat);
$the_cat_ID = get_cat_ID($the_cat_name);
}
if($the_cat_ID == 4){
echo "parent cat $the_cat_ID <br />";
}
?>
register_sidebars(1,array('name' => 'Magazine','before_widget' => '<div id="%1$s" class="block widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));