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
// Add this to your wordpress themes functions.php to register widget with bootstrap's jumbotron styling | |
register_sidebar( array( | |
'name' => __( 'Featured below navigation', 'twentytwelve' ), | |
'id' => 'sidebar-featured', | |
'before_widget' => '<div class="jumbotron"><aside id="%1$s" class="container %2$s">', | |
'after_widget' => '</aside></div>', | |
'before_title' => '<h1>', |
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
// 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 = 'mymail@mail.com'; | |
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: 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
// 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
<!-- add this code in page.php to display Next page and Previous page link below pages in WordPress | |
this will display next and previous page link not next previous post link | |
http://codex.wordpress.org/Next_and_Previous_Links#The_Next_and_Previous_Pages --> | |
<?php | |
$pagelist = get_pages('sort_column=menu_order&sort_order=asc'); | |
$pages = array(); | |
foreach ($pagelist as $page) { | |
$pages[] += $page->ID; | |
} |
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' | |
" ); |
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'); |
NewerOlder