Showing posts with label All in one SEO Wordpress. Show all posts
Showing posts with label All in one SEO Wordpress. Show all posts

WordPress Post Insert Using Ajax Page Without Refresh

WordPress Post Insert Using Ajax Page Without Refresh

Hi, Today Discussed WordPress Post Insert Using Ajax Page Without Refresh WordPress more then plugin used and then today we discussed blog posting contact form what ever posting insert database ajax without refresh stored db.

WordPress Complete content form-process.php wordpress all file is path wp-content/theme/_____
that the find functions for function.php or other file function wp_insert_post() is not defined, because the WordPress core was not loaded.

WordPress Post Insert Using Ajax Page Without Refresh
WordPress Post Insert Using Ajax Page Without Refresh

add_action( 'admin_ajax_your_form_action', 'wpse_126886_ajax_handler' );

function wpse_126886_ajax_handler() {

    // maybe check some permissions here, depending on your app
    if ( ! current_user_can( 'edit_posts' ) )
        exit;

    $post_data = array();
    //handle your form data here by accessing $_POST

    $new_post_ID = wp_insert_post( $post_data );

    // send some information back to the javascipt handler
    $response = array(
        'status' => '200',
        'message' => 'OK',
        'new_post_ID' => $new_post_ID
    );

    // normally, the script expects a json respone
    header( 'Content-Type: application/json; charset=utf-8' );
    echo json_encode( $response );

    exit; // important
}
your_form_action slug is the >> trigger of your Call Back. you have to append this slug to your request parameter named form input name normally get or post method using jquery ajax  passing data parameter or form data using .serialize(). Input type hidden field passing parameter.

<input type="hidden" name="action" value="your_form_slug" />

and then file path wp-admin/admin-ajax.php


$.ajax({
    type: "POST",
    url: "http://www.mysite.co.uk/wp-admin/admin-ajax.php",
    data: dataString,
    error: function(jqXHR, textStatus, errorThrown){                                        
        console.error("The following error occured: " + textStatus, errorThrown);                                                       
    },
    success: function(data) {                                       
        console.log("Hooray, it worked!");                                                                  
    }                              
});






How to Create New Modules Wordpress without plugin

How to Create New Modules Wordpress without plugin

 Hi, Today Discussed WordPress Theme customized and admin and frontend How to Create new modules Wordpress without plugin created this task discussed today.  New modules without plugin Follows Briefly discussed.

How to Create New Modules Wordpress without plugin
How to Create New Modules Wordpress without plugin
public_html/wp-content/themes/themesname/admin

Create Staff.php

<?php

//
// 'staff' Custom Post Type
//

// Register the Post Type - staff
// http://codex.wordpress.org/Function_Reference/register_post_type
add_action('init', 'register_staff');

function register_staff() {
 
 $labels = array(
  'name' => _x('Staff', 'post type general name'),
  'singular_name' => _x('Staff', 'post type singular name'),
  'add_new' => _x('Add New', 'Staff'),
  'add_new_item' => __('Add New Staff Member'),
  'edit_item' => __('Edit Staff'),
  'new_item' => __('New Staff'),
  'view_item' => __('View Staff'),
  'search_items' => __('Search Staffs'),
  'not_found' =>  __('Nothing found'),
  'not_found_in_trash' => __('Nothing found in Trash'),
  'parent_item_colon' => ''
 );
 
 $args = array(
  'labels' => $labels,
  'public' => true,
  'publicly_queryable' => true,
  'show_ui' => true,
  'query_var' => true,
  'rewrite' => array(
            'slug' => 'staff',
            'with_front' => false
            ),
  'has_archive' => 'staff',
  'capability_type' => 'page',
  'hierarchical' => false,
  'menu_position' => 22,
  'supports' => array('custom-fields') // 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' , 'page-attributes' 
 ); 
 
 register_post_type( 'staff' , $args );
}

//
// Create Profile Images sizes
if ( function_exists( 'add_image_size' ) ) {
 add_image_size( 'staff-profile-small', 45, 45, true ); 
 add_image_size( 'staff-profile-thumb', 124, 124, true );
 add_image_size( 'staff-profile', 204, 204, true );
}

//
// Add Meta Boxes
// http://codex.wordpress.org/Function_Reference/add_meta_box
//

function tpx_staff_init(){
 add_meta_box("metabox_staff_staff", "Staff Details", "metabox_staff_staff", "staff", "normal","high");
 add_meta_box("metabox_staff_description", "Description", "metabox_staff_description", "staff", "normal","high");
 
}
add_action("admin_init", "tpx_staff_init");

function metabox_staff_staff() {
 global $post;
 ?> 
    <div class="custom_meta">
     <div class="photo_profile">
            <label>Photo</label>
         <div class="fileWrapper"><?php
   $photo_profileID = get_post_meta($post->ID, 'staff_file_photo_profile', true);
   $photoArray = wp_get_attachment_image_src( $photo_profileID, 'staff-profile-thumb', false);
   $photoSrc = $photoArray[0];
   if($photoSrc){
    echo '<a class="photo"><img src="' . $photoSrc . '" alt="staffimage" /></a>';
   } else {
    echo '<a class="photo"><span>Upload Photo</span></a>';
   }
   ?>
            <input type="file" name="staff_file_photo_profile" /></div>
        </div>
     <ul class="formfields">
         <li>
            <label>First Name</label>
            <?php tpx_meta_input_text('staff_name_first'); ?>
            </li>
         <li>
            <label>Surname</label>
            <?php tpx_meta_input_text('staff_name_last'); ?>
            </li>
         <li>
            <label>Position</label>
            <?php tpx_meta_input_text('staff_position'); ?>
            </li>
        </ul>
    </div>
 <?php 
}
function metabox_staff_description() {
 global $post;
 ?>
    <div class="custom_meta">
     <?php 
     $staff_description = get_post_meta($post->ID, 'staff_description', true);
  the_editor($staff_description, 'staff_description', 'title', false, 1); ?>
    </div>
<?php
}
add_action('save_post', 'save_staff_meta');

function save_staff_meta(){
 global $post, $initLoop;
 $prefix = "staff_";
 $initLoop = true;
 
 //Upload Headshot
 foreach($_FILES as $field => $file){
  if($field == 'staff_file_photo_profile'){
   $filename = $_POST['staff_name_first'] . ' ' . $_POST['staff_name_last'] . ' Profile Photo';
   tpx_save_attachement($file, $post->ID, $filename, 'staff_file_photo_profile');
   //Remove it from the array to avoid duplicates.
   unset($_FILES[$field]);
  }
 }
 
 //Normal Inputs
 foreach($_POST as $field => $value){
  $has_prefix = strstr($field, $prefix);
    
  if($has_prefix){
   //Capitalize Name
   if($field == 'staff_name_first') $value = ucwords($value);
   if($field == 'staff_name_last') $value = ucwords($value);
   
   if($value){
    update_post_meta($post->ID, $field, $value); // Save Value
   } else {
    delete_post_meta($post->ID, $field); // Remove it if its not there
   }
  } 
 }
}

add_filter('wp_insert_post_data', 'update_staff_title', 10, 2);

function update_staff_title($data, $postarr){
 if($data['post_type'] == 'staff' && $_POST['staff_name_first']){
  $new_title = $_POST['staff_name_first'] . ' ' . $_POST['staff_name_last'];
  $new_slug = strtolower($_POST['staff_name_first']) . '-' . strtolower($_POST['staff_name_last']);
  $new_slug = str_replace(' ', '', $new_slug);
  $data['post_title'] = ucwords($new_title);
  $data['post_name'] = $new_slug;
 }
 return $data;
}


//
// Sort Staff Menu
//

// add the admin options page
add_action('admin_menu', 'tpx_add_page_sort_staff');
function tpx_add_page_sort_staff() {
 add_submenu_page('edit.php?post_type=staff', 'Sort Staff', 'Sort Staff', 'edit_pages', 'tpx-staff-sort', 'tpx_options_staff_sort');
 add_submenu_page('edit.php?post_type=staff', 'Staff Overview', 'Overview', 'edit_pages', 'tpx-staff-overview', 'tpx_options_staff_overview');
}

//
// Sort Staff Page
//
function tpx_options_staff_sort() {
 $tpx_options_staff_sort = get_option( 'tpx_options_staff_sort');
?>
    <div class="wrap">
    <h2>Sort Staff</h2>
    <p>Click and Drag to sort the order of staff members</p>
    <div id="poststuff" class="tpx_options">
    <form action="options.php" method="post">
    <?php settings_fields('tpx_options_staff_sort'); ?>
    <ul class="tpx_sort_list">
     <?php
  $args = array(
   'post_type' => 'staff',
   'orderby' => 'menu_order',
   'order' => 'ASC',
   'posts_per_page' => -1
  );
  $staff_list = get_posts($args);
  foreach($staff_list as $staff){
   echo '<li class="draggable" id="' . $staff->ID . '">'. $staff->post_title . '<li>';
  }
  ?>
    </ul>
    <input name="tpx_options_staff_sort[staff_order]" type="hidden" value="" class="sort_value" />
    <input name="Submit" type="submit" value="<?php esc_attr_e('Publish'); ?>" class="button-primary" />
    </form></div></div>
<?php
}


//
// Staff Overview Page
//

function tpx_options_staff_overview() {
 $tpx_options_staff_overview = get_option( 'tpx_options_staff_overview');
?>
    <div class="wrap">
    <h2>Staff Overview</h2>
    <p>This text will appear on the front page of the website.</p>
    <div id="poststuff" class="tpx_options tpx_options_staff_overview">
    <form action="options.php" method="post" enctype="multipart/form-data" encoding="multipart/form-data"  accept-charset="utf-8">
    <?php settings_fields('tpx_options_staff_overview'); ?>
    <div class="feature_image ">
        <h3>Feature Image</h3>
        <?php 
        $attachment_ID = $tpx_options_staff_overview['feature_id'];
        tpx_attachment_uploader($attachment_ID, 'feature_attachment', 'photo-medium') 
  ?>
    </div>
    <div class="tiny_mce_wrapper"><?php the_editor($tpx_options_staff_overview['html'], 'tpx_options_staff_overview[html]', 'title', false, 1); ?></div>
    <input name="Submit" type="submit" value="<?php esc_attr_e('Publish'); ?>" class="button-primary" />
    </form></div></div>
<?php
}


// add the admin settings and such
add_action('admin_init', 'tpx_staff_admin_init');

function tpx_staff_admin_init(){
 register_setting( 'tpx_options_staff_sort', 'tpx_options_staff_sort', 'tpx_options_staff_sort_validate' );
 register_setting( 'tpx_options_staff_overview', 'tpx_options_staff_overview', 'tpx_options_staff_overview_validate' );
 add_settings_section('tpx_staff_main', 'Main Settings', 'tpx_staff_section_text', 'tpx_staff_section');
 add_filter( 'option_page_capability_tpx_options_staff_sort', 'tpx_options_staff_sort_capability' );
}
function tpx_options_staff_sort_capability( $capability ) {
 return 'edit_pages';
}

// validate our options
function tpx_options_staff_sort_validate($input) {
 $list_string = $input['staff_order'];
 if($list_string){
  $IDs = explode(',', $list_string);
  $count = 0;
  //print_r($staff_IDs);
  foreach($IDs as $ID){
   if($ID != ''){
    $staff_post = array();
    $staff_post['ID'] = $ID;
    $staff_post['menu_order'] = $count;
    wp_update_post($staff_post);
    $count++;
   } else {
    unset($ID);
   }
  }
  $newinput['staff_order'] = implode(',', $IDs);
 }
 return $newinput;
}

// validate our options
function tpx_options_staff_overview_validate($input) {
 $attachment_id = tpx_save_attachement($_FILES['feature_attachment'], 0, 0, 0, true);
 if($_POST['remove_feature_attachment']) $newinput['feature_id'] = '';
 //echo '$attachment_id - ' . $attachment_id;
 if($attachment_id) $newinput['feature_id'] = $attachment_id;
 $newinput['html'] = $input['html'];
 return $newinput;
}
?>
Create Function.php

Include('staff.php');
function menu_order_filter($menu) {
 $dev_menu = array(
   
  'edit.php?post_type=staff',  
  
  );
 array_splice($menu, 1, 0, $dev_menu);
 return array_unique($menu);
}

add_filter('custom_menu_order', create_function('', 'return true;'));
add_filter('menu_order', 'menu_order_filter');
Frontend
public_html/wp-content/themes/themename

Create sidebar-staff-profiles.php


<div class="staff_profiles">
<ul class="staff">
<?php
$args = array(
 'post_type' => 'staff',
 'posts_per_page' => -1,
 'orderby' => 'menu_order',
 'order' => 'ASC'
);
$staffs = get_posts($args);
foreach($staffs as $staff){
 $profile_id = get_post_meta($staff->ID, 'staff_file_photo_profile', true);
 $profile_img = tpx_attachment_src($profile_id, 'staff-profile-thumb');
 $fname = get_post_meta($staff->ID, 'staff_name_first', true);
 $lname = get_post_meta($staff->ID, 'staff_name_last', true);
 setup_postdata($staff);
?>
 <li>
     <?php
  if($profile_img){ 
  ?>
        <div class="row">

     <div class="small-12 large-4 columns headshot">
         <a href="<?php echo get_permalink($staff->ID) ?>">
<img src="<?php echo $profile_img ?>" alt="vinoth" class="photo"/>
</a><!---->
        </div>
        <?php } ?>
        <div class="small-12 large-8 columns details">
            <h4 class="name">
                <?php
                echo $fname . ' ' . $lname
                ?>
            </h4>
            <div class="excerpt">
                <?php
                $excerpt = substr(get_post_meta($staff->ID, 'staff_description', true), 0, 180) . '...';
                echo wpautop($excerpt);
                ?>
            </div>
            <div class="readmore"><a href="<?php echo get_permalink($staff->ID) ?>" class="button small">View <?php echo $fname ?>'s Profile</a></div>
        </div>
        </div>
    </li>
 
<?php  } ?>
</ul>
</div>
Create Single-staff.php

<?php get_header(); ?>
<section class="feature fixed bg-1">
 <div class="row">
        <div class="small-12 columns">
    <?php 
    $current_post_type = get_post_type_object(get_post_type($post->ID));
    ?>
         <ul class="breadcrumb">
       <li><a href="<?php echo get_permalink(6) ?>">About Us</a></li>
                <li><?php echo $post->post_title ?></li>
            </ul>
        </div>
    </div>
</section>
<section class="main">
    <div class="row">
     <?php 
  $profile_id = get_post_meta($post->ID, 'staff_file_photo_profile', true);
  $profile_img = tpx_attachment_src($profile_id, 'staff-profile');
  if($profile_img){
  ?>
     <div class="small-12 medium-4 large-3 columns mrg-1">
            <div class="headshot">
         <?php
   echo '<img src="' . $profile_img . '" alt="singlestaffphotos" class="photo" />';
   ?>
            </div>
        </div>
        <?php } // endif ?>
        <div class="small-12 medium-8 large-9 columns">
            <div class="page content">
                <?php if (have_posts()) : ?>
                    <?php while (have_posts()) : the_post(); ?>    
                        <article class="tiny_mce">
                        <?php echo wpautop(get_post_meta($post->ID, 'staff_description', true)) ?>
                        </article>
                    <?php endwhile; ?>
                <?php endif; ?>
                <div class="options"><a href="<?php echo get_permalink(6) ?>" class="button back">All Staff</a></div>
            </div>
        </div>
    </div>
</section>
<?php get_footer(); ?>

All in one SEO Wordpress

All in one SEO Wordpress

All in one SEO is Wordpress Most using Search Engine Optimized Plugin. This Plugin Compare SEO Yoast is Most used and user friendly easily optimized Plugin in All in One SEO Plugin. This Plugin More then keyword put this single page and easily write meta keyword and meta description and meta title. Most Top 5 Plugin in Wordpress
All in one SEO Wordpress
All in one SEO Wordpress

Features:
  1. Support for SEO on custom post types
  2. Google Analytics support.
  3. Fine tune page Navigational links
  4. XML sitemap.
  5. Automatically generate meta tag.
  6. Translate 48 Language.
  7. Built-in API so other plugins/themes can access and extend functionality
XML Sitemap
XML Sitemap
All in One Seo XML sitemap Generate follow and index no index settings this image. default generated xml sitemap and custom link settings page in this plugin.

display settings
display settings

All in One SEO display settings page post and media and locations show column lables customized field easily this plugin.
Menu
Menu

All in One SEO Plugin is perfect Search Engine Optimized Plugin this Plugin Download Click Here