WP for Wordpress

1 How to remove or turn off comments on wordpress pages



In many situation, we use wordpress pages as static page which is not updated in near future, for that pages we don't need comments function.

it is very simple remove comments from wordpress pages just "comment or remove" a line of code form your theme page.php.

Go to your themes page.php this page is located on themes root.

[ sometimes page.php file uses page content template something like get_template_part( 'content', 'page' ); ]

if so just go to "content-page.php" file and "comment or remove" the following code

<?php// comments_template( '', true ); ?>

That's it happy blogging :)
[Read More...]


1 How to remove product review stars from woocommerce products



Reviews and rating are mostly used for user interactive, most of the times very useful while choosing a product, our first impression is goes on the rating of an item and subsequently the reviews.

Some times it goes terrific if some worst or unhappy customer try to rate bad (we have control over the review in admin panel) anyway this may lost product sales.

 To turn off or remove the reviews in Single Product page simply add the following code in themes function.php  

remove_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 ); 

remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_reviews_panel', 30 ); that's it.

 Finlay if you decide it no longer need in products archive page just add the following css code in style.css.  

.star-rating { display: none !important; }
[Read More...]


WooCommerce DHL shipping plugin by 1stdeveloper.com




The WooCommerce DHL Shipping plugin allows a woocommerce store to obtain Real-time shipping rates for your orders dynamically via the DHL Shipping API. this plugin will calculate shipping charges based on weight and dimension for the complete set of DHL Shipping Services from your shop to anywhere.

 This plugin primarily works with Dimension Unit IN (Inches) , CM (Centimeters) and Weight Unit in KG (Kilograms), LB (Pounds).

 The WooCommerce DHL Shipping plugin can calculate Shipping charges for both domestic and international services. Shipping services
  1. DOMESTIC EXPRESS 12:00
  2. B2C
  3. B2C
  4. JETLINE
  5. SPRINTLINE
  6. SECURELINE
  7. EXPRESS EASY
  8. EXPRESS EASY
  9. EUROPACK
  10. AUTO REVERSALS
  11. BREAK BULK EXPRESS
  12. MEDICAL EXPRESS
  13. EXPRESS WORLDWIDE
  14. EXPRESS 9:00
  15. FREIGHT WORLDWIDE
  16. DOMESTIC ECONOMY SELECT
  17. ECONOMY SELECT
  18. BREAK BULK ECONOMY
  19. JUMBO BOX
  20. EXPRESS 9:00
  21. EXPRESS 10:30
  22. EXPRESS 10:30
  23. DOMESTIC EXPRESS
  24. DOM EXPRESS 10:30
  25. EXPRESS WORLDWIDE
  26. MEDICAL EXPRESS
  27. GLOBALMAIL BUSINESS
  28. SAME DAY
  29. EXPRESS 12:00
  30. EXPRESS WORLDWIDE
  31. EUROPACK
  32. ECONOMY SELECT
  33. EXPRESS ENVELOPE
  34. EXPRESS 12:00
Key Features
  1. DHL Plugin for WooCommerce.
  2. Realtime shipping rates from DHL API.
  3. Multiple shipping services options.
  4. DHL Currency option.
  5. DHL Insurance option.
  6. DHL Shipping Fallback option.
  7. Domestic shipping services option.(ie. DOMESTIC EXPRESS).
  8. International shipping services option(ie. Express Worldwide).
  9. DHL Account Number options for discount.
  10. Easy to Install & use.
[Read More...]


0 How to recover wordpress from "Briefly Unavailable for Scheduled Maintenance Error in WordPress"



A common problem when updating WordPress on a shared hosting is that the update process may be timeout due to server load or memory exhausted (Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13897 bytes) in /home/xxxxx/public_html/wordpress/wp-includes/update.php on line 201) when site or plugin update interrupts this will leaving your site in maintenance mode just show this msg "Briefly Unavailable for Scheduled Maintenance Error in WordPress"

 Here i can explain how to recover wordpress from "Briefly Unavailable for Scheduled Maintenance Error in WordPress".

Normally when updating wordpress core or plugin a .maintenance file will be created on your wordpress installtion root. During the update process, WordPress downloads necessary update files to your server, extracts them, and installs new files. WordPress also puts your site on maintenance mode and displays the “Briefly unavailable for scheduled maintenance” notice during this process.

 To fix this issue simple delete the .maintenance file and make sure the wordpress successfully updated if not please update manually. Once you have deleted this file your site back to normal.
[Read More...]


0 How to get woocommerece product gallery image url



In woocommerce it is easy to get product gallery image url, First of all just find the attachment id of the product that you want to find the gallery image url. $attachment_ids = $product->get_gallery_attachment_ids(); the $product is the global variable. To get each image link in a gallery, simply use a for loop with wp_get_attachment_url( $attachment_id ) function and pass attachment id As a argument
get_gallery_attachment_ids();

foreach( $attachment_ids as $attachment_id ) 
{
  echo $image_link = wp_get_attachment_url( $attachment_id );
}
?>
Now you get all the links of a product image galley and can use it with list item to form a Awesome carousal. Hope this will helpful :)
[Read More...]


0 Remove edit, view, trash and quick edit links within custom post type



Adding this snippet to the functions.php of your wordpress theme or your plugin will remove the edit, view, trash and quick edit links that you see when you mouse over a post type list.


add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 );
function remove_row_actions( $actions )
{
    if( get_post_type() === 'your_post_type' )
        unset( $actions['edit'] );
        unset( $actions['view'] );
        unset( $actions['trash'] );
        unset( $actions['inline hide-if-no-js'] );
    return $actions;
}
 
you can replace your_post_type with your preferred post typle like books, videos.. 
[Read More...]


0 How to Remove Width and Height Attributes From wordpress post images



When you upload an image through the WordPress media uploader and then insert it into the editor, it comes with width and height attributes. These are normally desirable, as it assists the browser in making the appropriate room for the image during layout.

But some times the width and height attributes no longer needed to  a post attachment image or featured image so that situation you can remove with following snippet


add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );

function remove_width_attribute( $html ) {
   $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
   return $html;
}
 
[Read More...]


0 How to change the WordPress default email From name and address



You are probably  already noticed, that every time someone submitted a comment on your blog, signed up as a user or did anything that required WordPress to generate and send an e-mail, by default the “From Name” in that message appeared as “WordPress” and “From” address was “wordpress@your-domain.com”.

If this is not the way you want it – read on, as there is an easy way of customizing both these fields.

So how can you change these WordPress default email settings for FromName and From address.

you can easily change it by adding a filter to  your themes functions.php file



wp_mail_from_name for name and  wp_mail_from to change the from email

/** changing default wordpres email settings */
 
add_filter('wp_mail_from', 'tr_mail_from');
add_filter('wp_mail_from_name', 'tr_mail_from_name');
 
function tr_mail_from($old) {
 return 'your email address';
}
function tr_mail_from_name($old) {
 return 'your name or your website';
}
 

Now, save functions.php file and upload.

These filters will simply override default WordPress email settings.
[Read More...]


0 Wordpress Vertical News Scroller plugin (JM News Scroller)



JM News Scroller Plugin is a jquery based wordpress plugin which is used to show the wordpress news, posts with various12 Easing effects with Two Directions(Up, Down).

It can be integrated in the sidebar area on your Blog or Website. With JM News Scroller Plugin you can easily integrate the existing posts or your own news with Title, Image and Description. This plugin is compatible up to WordPress Version: 3.8.1.


JM News Scroller

Features

  1. JQuery Vertical News Scroller (Without Marquee Tag)
  2. Cross browser compatible
  3. 12 Amazing Easing Effects
  4. Two Directions (Bottom to Top — Up, Top to Bottom — Down )
  5. Thumbnail Support
  6. Easily Add Existing Posts.
  7. Add Any Number of news.
  8. Display desired number of news to users.
  9. Admin can manage scrolling news speed,Title Link and Visible items.
  10. Add your Own News content with Thumbnails.
  11. Admin can limit content length.
  12. Admin can enable, disable thumbnail and content.
  13. Admin Can change Scroll Content Length, Scroll Direction,
    Scroller Effect, Title Color, Content Text Color, Border Color, Separator Color,
    Thumbnail Width and Thumbnail Height.
  14. Pause on Mouse Over
  15. No PHP or HTML Skills need to Integrate JM News Scroller plugin.
  16. Clear Documentation with Screenshots
[Read More...]


1 Wordpress AJAX Pagination plugin (JM WP Ajax PAgination)



JM WP Ajax Pagination, a simple and flexible AJAX pagination plugin for WordPress posts, comments. So no need to reload entire page

again for Next Page items. it also Update the current page url on browser Address bar and track AJAX calls via Google Analytics. JM WP Ajax Pagination comes with ten predefined color schemes for Pagination.

JM News Scroller

Features

  • 1.Ajax Pagination
  • 2.Cross browser compatible
  • 3.Pagination for Posts, comments
  • 4.10 Different Color Schemes
  • 5.Admin can change Prev, Next Label.
  • 6.Can Upload your Own Loader image
  • 7.Can control Pagination Range, Anchor, Gap.
  • 8.Enable Google Tracking for AJAX clicks
  • 9.Highly customizable
  • 10.Clear Documentation with Screenshots
[Read More...]


0 Frequently Used WordPress Action Hooks For Plugin Development



Hooks, Actions and Filters
Hooks are provided by WordPress to allow your plugin to 'hook into' the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks:

  1. Actions
  2. Filters

You can see many WordPress action hooks when you are developing a plugin for WordPress, but some WordPress hooks are used more than other hooks. So for developing a plugin, you should have some knowledge of these hooks

plugins_loaded 

This one is the most important hook in any plugin development process. plugins_loaded is fired after all the WordPress files are loaded on the page but before the pluggable functions, then WordPress starts executing everything. So now you can understand, no code snippet will run until this hook is fired

<?php
add_action('plugins_loaded', 'display_my_msg');

function display_my_msg() {
add_action('wp_footer', 'display_message', 100);
}

function display_message() {
echo 'This is dummy Text';
}

?>

init

This hook is fired after everything is set up in WordPress. WordPress also tries to add a plenty of things, for example, registration of taxanomies, initialization of the default widgets and post types. You can say that everything is ready when it will come to this hook, so your plugin whatever you are developing will perhaps use init hook for anything it needs to do, when entire information of WordPress is available to use.

<?php
add_action('init', 'excerpts_to_page_type');

function excerpts_to_page_type() {
add_post_type_support('page', array('excerpt'));
}
?>
 

wp_head

You can see the difference with and without using wp_head in your template. Without this hook you will not see anything besides your own written code, but with this hook you will see extra files like javascript, css etc after your written code in the head section.

<?php
add_action('wp_head', 'tr_add_meta_desc');

function tr_add_meta_desc() {
//Getting the blog description
$desc = esc_attr(get_bloginfo('description'));
}

//Check meta description is set or not
if(!empty($desc)) {
echo '<meta name="description" content="' . $desc . '" />';
}
?>

template_redirect

The importance of this hook is that at this point WordPress knows which page or post a visitor is viewing. It is just executed before the theme is chosen for the particular page view. template_redirect doesn’t fire in the admin area, it just fired only on the front side. The hook is very useful if you want to load a specific piece of code only for certain page views.

<?php
add_action('template_redirect', 'add_my_css_file');

function add_my_css_file() {

if(is_singular('post')) {
wp_enque_style('add_css', 'my_custom.css', false, 0.1, 'screen');

}
}
?>
 

admin_menu

admin_menu hook is just for admin pages when page loads. If your plugin doesn’t need to execute in the front end, you can use this hook because whenever your plugin works directly in the admin side, you would absolutely use admin_menu to run your code.

<?php
add_action('admin_menu' , 'my_plugin_page');

function my_plugin_page() {

add_options_page('My Page', 'My Page', 'manage_options', 'my_plugin', 'my_plugin_page");

}
?>
[Read More...]


0 How To Prevent WordPress Plugin Files from Direct Access?



When creating WordPress plugins, it is always advisable to follow maximum security measures. This makes your plugin more stable and acceptable by other users.

 One such security check is to prevent direct access of plugin files by a user. For that add the following code to the top of main plugin php file.

 if(!defined('ABSPATH'))
die('Direct access of plugin file not allowed');
[Read More...]


0 How to Add a Setting Page To Custom Post Type



In this Article I am going to Explain how to add a Setting Page To Custom Post Type, Recently I needed to add a settings page to two custom post types I am developing a plugin for a clint . Adding an admin page to one of the default menus in the WordPress control panel is easy. The WordPress Codex has a nice article explaining how to hook sub-menu pages to “posts” “media” “categories” and so on.

It’s very useful for plugins and theme authors. One thing the article doesn’t do is explain how to add a sub-menu to a custom post type. Turns out, it’s easy to do. Here’s the code we will use and a brief explanation of it.

<?php
add_action(‘admin_menu’ , ‘tradmin_page_settings’);
function tradmin_page_settings() {
add_submenu_page(‘edit.php?post_type=custom’, ‘Custom Post Type Admin’, ‘Custom Settings’, ‘edit_posts’, basename(__FILE__), ‘custom_function’);
}
?>

first of all we add an action for our new admin menu,  Once we’ve done that, you need to create a function for your page(s). Here’s what the function does. First we are saying the place we’d like the menu to go is with the post type we’ve defined called “custom.” That’s what the edit.php?post_type=custom part is dong. Just replace “custom” with the post type that you’ve already defined and the menu will be added there
add_action(‘admin_menu’ , ‘tradmin_page_settings’);

Our next two options deal with titles and menu names. The ‘Custom Post Type Admin’ is the page title that will appear at the top of your browser page while using the page. The ‘Custom Settings’ is the name that will appear in your menu under your custom post type. 

The ‘edit_posts’ set the minimum capabilities a user has to have in order to access this page. If the current user can edit posts then they can access our admin page

The ‘basename(__FILE__)’ serves as the slug that will go in your URL for the admin page you create. Lastly the ‘custom_function’ is optional and will call any functions you need on your new admin page
[Read More...]


0 How to Hide WooCommerce Product Images



You can hide WooCommerce product images from the product detail pages by using the following code. To remove the image add the line of code below to your theme’s functions.php file (found at wp-content/themes/themename/functions.php):

remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); 

This removes the featured product image from the product page but can leave the column intact, pushing the page content over and looking horrible: the above code hides the actual image and the place still shows empty rectangle.

 to remove fully simple add the css code to your theme style sheet
 .single-product .product .summary { width: auto; }
[Read More...]


0 How to Change WooCommerce number of products displayed per page



By Default Woocommerce Archive page display the products with pagination. means that each page with certain amount of products that is defined in wordpress reading settings. If you want to display more products than defined ex( 10,12 or 20) per page, simply add the following code in your theme functions.php // Display 24 products per page. Goes in functions.php add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 ); This means that each page contains 24 products you can change it as per your need...
[Read More...]


AddThis

 

Recent Comments

Return to top of page Copyright © 2014