Thired party url plugin available for wordpress wevsite. so now in wordpress no need to add third party url with target=”_blank”
Hide comment on media attachment page
Add Below code in function.php
1 2 3 4 5 6 7 8 |
function filter_media_comment_rpl( $open, $postidn ) { $post = get_post( $postidn ); if( $post->post_type == 'attachment' ) { return false; } return $open; } add_filter( 'comments_open', 'filter_media_comment_rpl', 10 , 2 ); |
Remove post type slug from url and replace with terms
Copy below code in your function.php file.
Create post type with url taxonomy term
“our_homes” taxonomy terms and “property” Post type.
you must be assign category else it will error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
<?php add_action('init', 'wr_property'); function wr_property() { register_taxonomy( 'our_homes', 'property', array( 'label' => 'Taxonomy', 'singular_label' => 'taxonomy', 'hierarchical' => true, 'query_var' => true, 'rewrite' => array('slug' => 'taxonomyname'), ) ); $labels = array( 'name' => _x('Property', 'post type general name'), 'singular_name' => _x('Property', 'post type singular name') ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','thumbnail', 'excerpt'), 'rewrite' => array( //'slug' => 'event', 'slug' => '/%our_homes%', 'with_front' => false //this is must be false for hide post type slug in url ), 'has_archive' => 'property' ); register_post_type( 'property' , $args ); flush_rewrite_rules(); } if($_POST) { add_action('save_post', 'save_details'); //create custom post type } // use this code for taxomy remove from url in custom post yep // in post type set 'with_front' => false add_filter('post_type_link', 'property_permalink_structure', 10, 4); function property_permalink_structure($post_link, $post, $leavename, $sample) { $our_homes_term = get_the_terms( $post->ID, 'our_homes' ); //our_homes taxonomy term if($our_homes_term) { if ( false !== strpos( $post_link, '%our_homes%' ) ) { $post_link = str_replace( '%our_homes%', array_pop( $our_homes_term )->slug, $post_link ); } } return $post_link; } ?> |
Remove taxonomy slug from url
you can add below plugin to remoe taxonomy name from term url link.
Update the_excerpt word length
Using given code you can increase or decrease wordpress default function length.
the_excerpt()
you can just coppy and past below code in function.php file and update text length using update return value.
1 2 3 4 |
function wordpresshtml_length( $length ) { return 20; } add_filter( 'excerpt_length', 'wordpresshtml_length', 999 ); |

Wp to add custom field display in admin post list
You can add any custom field in your admin post type / page / custom post type list using below code.
Below code example for display event start date in event post type admin list.
here in below example “event” is custom post type and “event_date_start” is custom field.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
add_filter('manage_event_posts_columns', 'hs_event_table_head'); function hs_event_table_head( $columns ) { $columns['event_date_start'] = '<sapn>Start Date</sapn>'; return $columns; } add_action( 'manage_event_posts_custom_column', 'hs_event_table_content', 10, 2 ); function hs_event_table_content( $column_name, $post_id ) { if( $column_name == 'event_date_start' ) { $featured_product = get_post_meta( $post_id, 'event_date_start', true ); echo $featured_product; } } |
wordpress 4.7.3 version for security
You can see mor update on wp site.
it will support follow 6 task.
- Cross-site scripting (XSS) via media file metadata.
- Control characters can trick redirect URL validation.
- Unintended files can be deleted by administrators using the plugin deletion functionality.
- Cross-site scripting (XSS) via video URL in YouTube embeds.
- Cross-site scripting (XSS) via taxonomy term names.
- Cross-site request forgery (CSRF) in Press This leading to excessive use of server resources.
Woocommerce to add custom shipping
You can add custom shipping or fees on your woocommerce cart using below code.
make your additional charge add in eCommerce cart page add in total value based on cart or based on per product.
just add below code in your function.php file and see magic in cart page.
1 2 3 4 5 6 7 8 9 10 11 |
add_action('woocommerce_cart_calculate_fees' , 'add_custom_shipping_your'); function add_custom_shipping_your( WC_Cart $cart ) { $fees = 0; $child_proid=''; foreach( $cart-&gt;get_cart() as $item ) { $fees += 10; //increse 10$ or rupis per product if( $fees != 0 ) { // update the descriptions here to view in cart $cart->add_fee('Custom (Shipping)', $fees); } } |
Contact form 7 data move to third party form
You can post your contact form 7 data to third party form. add below code in function.php. and add js in your js file. in js just change your id and class as per your requirement.
Third party form submition
when you use below code default contact form7 thankyou message not working so you need to java script to settimout() to add custom message using given script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
add_action('wpcf7_mail_sent', 'after_sent_mail'); function after_sent_mail( $contact_form ) { $title = $contact_form->title; $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); } if ( 'Inquiry' == $title ) { $name = $posted_data["name"]; $daughter = $posted_data["daughter"]; $email = $posted_data["email"]; $pincode = $posted_data["pincode"]; $phone = $posted_data["phone"]; $urgent = $posted_data["urgent"]; $age = $posted_data["age"]; // $post_items[] = 'oid=00D4000000xxxxx'; $post_items['name'] = $name; $post_items['daughter'] = $daughter; $post_items['email'] =$email; $post_items['pincode'] = $pincode; $post_items['phone'] = $phone; $post_items['urgent'] = $urgent; $post_items['age'] = $age; $url = 'http://www2.compassroseacademy.org/l/71982/2016-12-27/4njtj5'; $fields = $post_items; //print_r($fields); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); //wp_redirect(get_site_url().'/inquiry/?result=success'); } } ?> <script> $('#wpcf7-f253-p256-o1 .wpcf7-submit').click(function(e) { // alert(); setTimeout(function(){ $('.wpcf7-response-output').addClass('wpcf7-mail-sent-ok'); $('.wpcf7-response-output').html('Thank you for your message. It has been sent.'); $('.wpcf7-response-output').css('display','block'); $('.wpcf7-form').trigger('reset'); }, 4000); }); ?> |
Remove css and script on specific wordpress page
On your wordpress blog you have multiple style and script from plugin or them but you have no need to display all style and script on all page you can follow below step to dequ.
you can just fien enque script name and dequeu it on specific page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 ); function wpdocs_dequeue_style() { if(is_front_page()){ wp_dequeue_style( 'berocket_lmp_style' ); wp_dequeue_style( 'font-awesome' ); wp_dequeue_style( 'contact-form-7' ); wp_dequeue_style('woocommerce_prettyPhoto_css'); wp_dequeue_style('quote-request-style'); } } add_action( 'wp_print_styles', 'wpdocs_dequeue_style', 100 ); function wpdocs_dequeue_script() { if(is_front_page()){ wp_dequeue_script( 'berocket_lmp_js' ); wp_dequeue_script( 'contact-form-7' ); wp_dequeue_script( 'jquery-form' ); wp_dequeue_script( 'jquote-request-js' ); } } add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 ); |