Monthly Archives: June 2015

Send email on saving post type using hook

functions.php


add_action( 'save_post', 'my_project_updated_send_emails' );
function my_project_updated_send_emails(){
if( get_post_type() == 'birs_client' ){
wp_mail('ravi.loyalweb@gmail.com','subject ok 5','message ok 5');
}
}

Advertisements

Create Child theme in wordpress

style.css



/*
 Theme Name:     Twenty Sixteen Child Theme
 Template:       twentysixteen
*/

functions.php


add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    //wp_enqueue_style( 'child-style',get_stylesheet_directory_uri() . '/style.css',array('parent-style'));
}

main post under sub posts by page attribute

functions.php


/* custom post type trove */

function trove_custom_init() {
$labels = array(
'name' => __('Treasure Trove','themename'),
'singular_name' => __('trove','themename'),
'add_new' => __('Add New','themename'),
'add_new_item' => __('Add New Treasure Trove','themename'),
'edit_item' => __('Edit Treasure Trove','themename'),
'new_item' => __('New Treasure Trove','themename'),
'all_items' => __('All Treasure Trove','themename'),
'view_item' => __('View Treasure Trove','themename'),
'search_items' => __('Search Treasure Trove','themename'),
'not_found' => __('No Treasure Trove found','themename'),
'not_found_in_trash' => __('No Treasure Trove found in Trash','themename'),
'parent_item_colon' => "",
'menu_name' => __('Treasure Trove','themename')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'trove' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'supports' => array( 'title', 'editor','thumbnail','page-attributes'),
);
register_post_type( 'trove', $args );
}
add_action( 'init', 'trove_custom_init' );

Display Posts


<div class="blog-details single">
<?php
global $post;
$troveargs = array(
'paged' => $paged,
'post_type' => 'trove',
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => 0
);
$trove_query = new WP_Query($troveargs);

while ( $trove_query->have_posts() ) : $trove_query->the_post();
//if ($post->post_parent == 0) {
?>
<div class="col-md-12 no-padding trovebox">
<h2>
<?php the_title(); ?>
</h2>
<p>
<?php the_content(); ?>
</p>
</div>
<?php
/* Start Second Loop of sub procuct listed under main product */
$troveargs_sub = array(
'paged' => $paged,
'post_type' => 'trove',
'post_status' => 'publish',
'order' => 'ASC',
'post_parent' => $post->ID
);
$trove_query_sub = new WP_Query($troveargs_sub);
while ( $trove_query_sub->have_posts() ) : $trove_query_sub->the_post();
//echo wp_get_post_parent_id( $post_ID );
?>
<div class="col-md-12 no-padding trovebox">
<h4>
<?php the_title(); ?>
</h4>
</div>
<?php endwhile;
/* End Second Loop*/
?>
<?php endwhile; ?>
</div>

%d bloggers like this: