This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original Source : http://www.elftronix.com/add-css-class-directly-to-wordpress-menu-item-link/ | |
// This is modified version of code from elftronix.com | |
// -1 will add custom CSS class to every menu item, while if you will use 1 ut will add Custom css classs to 1st link only. | |
// normally WordPress themes apply CSS classes to UL and li not a links, that's why you can use this code to add class to anchors. | |
// i used this code to apply .mdl-navigation__link class from Material Design Framework to anchors, when i was creating WordPress theme with material design. | |
//Step 1 : Add this to register functions.php navigation menu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#addthese two lines in the root folder of your old domain inside .htaccess file | |
RewriteEngine on | |
RewriteRule (.*) http://newdomain.com/$1 [R=301,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code will show message only on mobile devices | |
// only mobile users will see this message | |
// Source: https://www.cms2cms.com/blog/6-useful-yet-relatively-unknown-wordpress-functions/ | |
// Tested: WordPress 4.1 Jan 25 2015 | |
<?php if( wp_is_mobile() ) : ?> | |
Visit our website on your desktop for a richer user experience | |
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://www.cms2cms.com/blog/6-useful-yet-relatively-unknown-wordpress-functions/ | |
// This function will generate something like this | |
// This post was published 2 weeks ago | |
// Tested : WordPress 4.1 | |
<?php | |
echo 'This post was published ' . human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ago'; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference : https://www.cms2cms.com/blog/6-useful-yet-relatively-unknown-wordpress-functions/ | |
// add this code to sidebar.php or anywhere you want to display email addess | |
// remove <?php and ?> if you are going to paste this in functions.php | |
// Tested WordPress 4.1 Jan 25 2015 | |
<?php | |
$email = '[email protected]'; | |
echo 'You can contact me at ' . antispambot( $email ) . ' any time'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source http://wordpress.stackexchange.com/posts/28530/revisions | |
// Tested and worked on WordPress 4.1 Beta | |
//REMOVE VERSION STRING FROM HEADER | |
remove_action('wp_head', 'wp_generator'); | |
//HIDE LOGIN ERROR MESSAGES (Wrong Password, No Such User etc.) | |
add_filter('login_errors',create_function('$a', "return null;")); | |
// Remove admin name in comments class | |
// Source: http://www.wprecipes.com/wordpress-hack-remove-admin-name-in-comments-class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wordpress Custom Admin Footer | |
// customize admin footer text. Add this to functions.php | |
// Source http://wordpress.stackexchange.com/posts/6005/revisions | |
// Modified by Tahir Taous | |
// customize admin footer text Will be visible in Dashboard | |
function custom_admin_footer() { | |
echo 'Created By <a href="//tahirtaous.com/contact">Tahir Taous</a> '; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source : http://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for-your-functions-php-file | |
// unregister all default WP Widgets | |
function unregister_default_wp_widgets() { | |
unregister_widget('WP_Widget_Pages'); | |
unregister_widget('WP_Widget_Calendar'); | |
unregister_widget('WP_Widget_Archives'); | |
unregister_widget('WP_Widget_Links'); | |
unregister_widget('WP_Widget_Meta'); | |
unregister_widget('WP_Widget_Search'); | |
unregister_widget('WP_Widget_Text'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open you functions.php file and paste the following code: | |
// Save the file and open your blog homepage to run the code. Once done, there’s no need to keep the code snippet in your | |
// functions.php file, as it will always delete all post revisions. So simply remove it. | |
// http://www.wprecipes.com/easily-delete-wordpress-post-revisions-using-your-fuctions-php-file | |
$wpdb->query( " | |
DELETE FROM $wpdb->posts | |
WHERE post_type = 'revision' | |
" ); |
NewerOlder