This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function auto_featured_image() { | |
global $post; | |
if (!has_post_thumbnail($post->ID)) { | |
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); | |
if ($attached_image) { | |
foreach ($attached_image as $attachment_id => $attachment) { | |
set_post_thumbnail($post->ID, $attachment_id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gf_popup_shortcode( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'title' => '', | |
'id' => '', | |
'text' => '', | |
), $atts ) ); | |
return ' | |
<a class="gf-form-modal-trigger" href="" data-toggle="modal" data-target="#gf-popup-modal'.$id.'">'.$text.'</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_theme_support( 'post-thumbnails'); | |
=========================== | |
WordPress crop an image = 5 size. Sizes are given below | |
thumbnail: Thumbnail (default 150px x 150px max) | |
medium: Medium resolution (default 300px x 300px max) | |
large: Large resolution (default 640px x 640px max) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $post; | |
$args = array( 'posts_per_page' => -1, 'post_type'=> 'posttype', 'orderby' => 'menu_order', 'order' => 'ASC' ); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); ?> | |
<?php | |
$job_link= get_post_meta($post->ID, 'job_instructions', true); | |
?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_enqueue_scripts', 'jk_masonry' ); | |
function jk_masonry() { | |
wp_enqueue_script( 'jquery-masonry', array( 'jquery' ) ); | |
} | |
How to use? ======= | |
$('#container').masonry({ singleMode: true }); | |
OR =========== | |
$('#container').masonry({ columnWidth: 200 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post_list_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'count' => '', | |
), $atts) ); | |
$q = new WP_Query( | |
array('posts_per_page' => $count, 'post_type' => 'posttype', 'orderby' => 'menu_order','order' => 'ASC') | |
); | |
$list = '<div class="custom_post_list">'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_custom_theme_widgets() { | |
register_sidebar( array( | |
'name' => 'My Widget', | |
'id' => 'widget_id', | |
'before_widget' => '<div class="widget_div">', | |
'after_widget' => '</div>', | |
'before_title' => '<h2>', | |
'after_title' => '</h2>', | |
) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_theme_custom_meta_boxes() { | |
$post_meta_box = array( | |
'id' => 'post_meta_box', | |
'title' => 'Metabox', | |
'pages' => array( 'post' ), | |
'context' => 'normal', | |
'priority' => 'high', | |
'fields' => array( | |
array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Register custom post type | |
add_action( 'init', 'my_theme_custom_post' ); | |
function my_theme_custom_post() { | |
register_post_type( 'cpt', | |
array( | |
'labels' => array( | |
'name' => __( 'CPTs' ), | |
'singular_name' => __( 'CPT' ) | |
), |
NewerOlder