Skip to content

Instantly share code, notes, and snippets.

View TanvirAmi's full-sized avatar
🏠
Working from home

Tanvir TanvirAmi

🏠
Working from home
View GitHub Profile
<?php
/**
* Add Next Page/Page Break Button
* in WordPress Visual Editor
*/
function my_add_next_page_button( $buttons, $id ){
/* only add this for content editor */
if ( 'content' != $id )
return $buttons;
<!-- I got these buttons from simplesharebuttons.com -->
<div id="share-buttons">
<!-- Buffer -->
<a href="https://bufferapp.com/add?url=https://simplesharebuttons.com&amp;text=Simple Share Buttons" target="_blank">
<img src="https://simplesharebuttons.com/images/somacro/buffer.png" alt="Buffer" />
</a>
<!-- Digg -->
<a href="http://www.digg.com/submit?url=https://simplesharebuttons.com" target="_blank">
<?php
// If it's the blog
function is_blog() {
global $post;
$posttype = get_post_type( $post );
return ( ( ( is_archive() ) || ( is_author() ) || ( is_category() ) || ( is_home() ) || ( is_single() ) || ( is_tag() ) || ( is_search() ) ) && ( $posttype == 'post' ) ) ? true : false;
}
?>
<?php
//add hatom data
function add_suf_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if (is_home() || is_singular() || is_archive() ) {
$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
}
return $content;
@TanvirAmi
TanvirAmi / move-comment-field.php
Created January 31, 2016 14:43
Move up the filed above comment section in wordpress 4.4
<?php
function move_comment_field( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
add_filter( 'comment_form_fields', 'move_comment_field' );
?>
@TanvirAmi
TanvirAmi / html_link_in_excerpt.php
Last active December 15, 2015 17:06
This function will help to show links in wordpress excerpt.
@TanvirAmi
TanvirAmi / cat-id.php
Created December 15, 2015 16:57
Sometimes we need current category id in a current page for various operation in wordpress. By the way we can get current category id in wordpress.
<?php
$categories = get_the_category();
$x = $categories[0]->cat_ID;
print_r($x);
?>
@TanvirAmi
TanvirAmi / custom-comment-form.php
Created November 24, 2015 15:28
This function will remove the email and url field from wordpress comment form.
<?php
function remove_comment_fields($fields) {
unset($fields['email']);
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'remove_comment_fields');
?>
@TanvirAmi
TanvirAmi / exceprt-more.php
Created November 14, 2015 08:56
Change the "more" text of wordpress excerpt.
<?php
/**
* Change the excerpt more string.
* @param string $more
* @return string
*/
function custom_excerpt_more( $more ) {
return '&hellip;';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );
@TanvirAmi
TanvirAmi / custom-excerpt.php
Created November 14, 2015 08:53
Filtering the default excerpt in wordpress post.
<?php
/**
* Control excerpt length.
*/
function custom_excerpt_length( $length ) {
return 15;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
?>