WordPress admin side hook to add any functions in dashboard
To make any changes in the wordpress dashboard. admin_footer add_action(‘admin_footer’, ‘our_fun’); function our_fun() { echo ‘<script>alert(“bottom admmin page”)</script>’; }
WordPress pagination is not working
Add pagination as follows: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“post_type=products&posts_per_page=6&paged=$paged”); Include query_posts parameters in double quotes. query_posts(“post_type=products&posts_per_page=6&paged=$paged”);
Changing delimiter of default woocommerce breadcrumb
add_filter( ‘woocommerce_breadcrumb_defaults’, ‘myfun’ ); // function definition function myfun( $defaults ) { // Change delimeter as ‘>’ $defaults[‘delimiter’] = ” > “; return $defaults; }
Breadcrumbs without using plugin
Reference website: WordPress – How to Display Breadcrumb without Plugin
Woocommerce filter to set product default image
In function.php : // Add action to hook into the approp add_filter( ‘woocommerce_placeholder_img_src’, myfun’ ); /** * Function definition to new placeholder image URL. */ function myfun( $image_url ) { $img=get_option(‘home’); $img_url = $img.”/wp-content/themes/copier/images/border2.jpg”; // change this to the URL to your custom placeholder return $img_url; }
Getting category id of current post
<?php $categories = get_the_category( $post->ID ); $categories = (array) $categories[‘0’]; $catid=$categories[‘term_id’]; ?>
How to install a wordpress theme?
Download WordPress and install WordPress . for details see the link: http://www.howtofindit.in/how-to-install-wordpress-in-wamp-server/ Install wordpress them. for woo commerce, Storefront. The Official WooCommerce Theme. Download the theme from https://woocommerce.com/storefront/ link Extract the downloaded theme. Move into wordpress wp-content >> theme folder. Download the woocommerce plugin from https://wordpress.org/plugins/woocommerce/ Extract the plugin into wordpress wp-content >> plugin folder.…
Creating shortcode in wordpress
In function.php define the shortcode using add_shortcode: function myshortcode(){ global $post; echo “My post id: “.$post->ID; } add_shortcode( ‘myshortcodehere’, ‘myshortcode’ ); Here we created a shortcode with na”myshortcodehere” To print the id of current post. Call this shortcode as do_shortcode: <?php echo do_shortcode(‘[myshortcodehere]’); ?>
Worpdress mail function and php mail function
We cans end mail rom wordpress using both php mail function (mail();) and wordpress mail function wp_mail(wp_mail();). Php mail function: TO: sample@sample.com mail(“sample@sample.com”,”Subject”,”Message”); From wordpress using this function you will get mail with from field as server details. WordPress mail function: TO: sample@sample.com wp_mail(“sample@sample.com”,”Subject”,”Message”); From wordpress using this function you will get mail with from…
To get Structured data using print_r statement
To get structured data while printing a variable in php, first print a “pre” statement: Then print variable. echo “<pre>”; print_r($var);