Update record if exists, else write new record


 INSERT INTO upsert_table(id, name, value) VALUES(4,"Check_Upsert",888) ON DUPLICATE KEY UPDATE name = VALUES(name), value = VALUES(value);

If id=4 already there in table it will update values else write the new record in table


Disable the content editor for a specific page template

Use this snippet in your theme’s functions.php file to disable the editor for a specific page template.

add_action( 'admin_init', 'hide_editor' );

function hide_editor() {
    // Get the Post ID.
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    if( !isset( $post_id ) ) return;

    // Get the name of the Page Template file.
    $template_file = get_post_meta($post_id, '_wp_page_template', true);
    if($template_file == 'contact.php'){ // edit the template name
        remove_post_type_support('page', 'editor');

Date picker required doesn’t work in Contact Form 7

Date picker required doesn’t work in Contact Form 7

You need to edit core plugin files before that you need to save contact-form-7-datepicker folder for backup

You go to  wp-content/plugins/contact-form-7-datepicker/modules/date.php

Normal Code (Line Number :124)

if ('datetime*' == $type && empty($value)) {
    $result['valid'] = false;
    $result['reason'][$name] = wpcf7_get_message('invalid_required');
if (! empty($value) && ! self::is_valid_date($value)) {
    $result['valid'] = false;
    $result['reason'][$name] = wpcf7_get_message('invalid_datetime');

Change to below code

if ('date*' == $type && empty($value)) {
    $result['valid'] = false;
    $result['reason'] = array($name => wpcf7_get_message('invalid_required'));
if (! empty($value) && ! self::is_valid_date($value)) {
    $result['valid'] = false;
    $result['reason'] = array($name => wpcf7_get_message('invalid_datetime'));

Then I changed also time.php (from line 119) and datetime.php (from line 119) files in that similar way.
I hope this helps to you

How to get Custom Menu in Query Posts Wordpress

    $args = array(
    'post_type' => 'nav_menu_item', 'orderby'   => 'menu_order',
    'order'  => 'ASC',
    'tax_query' => array(
            'taxonomy' => 'nav_menu', 'field' => 'slug', 'terms' => 'my'        
while( have_posts()):the_post();
echo $post->ID;
endwhile; wp_reset_query();?>

Getting a Post’s Featured Image URL By Post ID

Getting a Post’s Featured Image URL By  Post ID

<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

<img src="<?php echo $feat_image; ?>" width="80" height="100" />

If Featured Image else your default image:

check below code:

<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

<?php if($feat_image) {?>
<img src="<?php echo $feat_image; ?>" width="80" height="100" />
<?php } else {?>
<img src="default.jpg" width="80" height="100" />
<?php } ?>


Display Child Pages title & content on Parent Page

Display all child and sub child pages using parent ID

This way the page that you are on will show in a post type the child pages of that page


$pages = get_pages('child_of=7&sort_column=post_date&sort_order=desc'); //Replace your parent id with 7
$count = 0;
foreach($pages as $page)
$content = $page->post_content;
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<p><?php echo $content ?></p>