Skip to content

Instantly share code, notes, and snippets.

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

Md Abul Bashar hmbashar

🏠
Working from home
View GitHub Profile
@hmbashar
hmbashar / cuxtom taxonomy in single.php
Created October 6, 2019 15:16
Show cuxtom taxonomy in the single page for cusotm post type
<?php
$cb_faq_cat = get_the_terms(get_the_ID(), 'cb_faq_cat');
if(is_array($cb_faq_cat)) {
foreach ($cb_faq_cat as $cb_cat) {
echo esc_html($cb_cat->name);
}
}
?>
<div class="social">
<p>Share This Post on:</p>
<!--Twitter-->
<a class="twitter" href="http://twitter.com/share?text=<?php echo urlencode(the_title()); ?>&url=<?php echo urlencode(the_permalink()); ?>&via=shemul49rmc&related=<?php echo urlencode("shemul49rmc:support me"); ?>"title="Share on Twitter" rel="nofollow" target="_blank">Twitter</a>
<!--Facebook-->
<a class="facebook" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>">Facebook</a>
<!--Google Plus-->
<a class="google-plus" target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>" onclick="window.open('https://plus.google.com/share?url=<?php the_permalink(); ?>','gplusshare','width=600,height=400,left='+(screen.availWidth/2-225)+',top='+(screen.availHeight/2-150)+'');return false;">Google+</a>
<!--Reddit-->
<a class="reddit" href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" titl
<?php
function post_format_metabox_js() {
if( get_post_type() === 'post'): ?>
<script type="text/javascript">
jQuery(document).ready(function(){
$id = jQuery('input[name="post_format"]:checked').attr('id');
@hmbashar
hmbashar / User id column in user page.php
Created October 2, 2019 21:39
show user id to user main page with a column
<?php
// Add Column for user id in user main page
function cb_author_user_id_column( $columns )
{
$columns['uid'] = 'ID';
return $columns;
}
//print suer id to user column
function cb_author_user_id_display_column( $empty, $column_name, $user_id )
@hmbashar
hmbashar / Sticky Header.js
Created September 20, 2019 08:32
sticky header secton or menu/ header section position fixed after scrolling
$(window).scroll(function() {
var windowSize = $(window).width();
var kotoDur = $(window).scrollTop();
var menurParHoisi = $(".header-section").scrollTop();
if (kotoDur > menurParHoisi && windowSize > 767) {
$('.header-section').addClass('header-position-fixed');
}else{
$('.header-section').removeClass('header-position-fixed');
<?php
function shape_custom_post_taxonomy() {
register_taxonomy(
'testimonial_category', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
'shape-testimonial', //post type name
array(
'hierarchical' => true,
'label' => 'Categories', //Display name
'query_var' => true,
'show_admin_column' => true,
@hmbashar
hmbashar / Avada Theme scripts handler.php
Created September 18, 2019 16:23
To build on what Michael C wrote, and based on another post that I came across (https://theme-fusion.com/forums/topic/related-posts-not-showing-on-post-pages/), I was able to put together a solution to this using the Avada Child Theme. I found that disabling Fusion Builder Elements in the Fusion Builder settings did not consistently remove the d…
<?php
add_action( 'wp_enqueue_scripts', 'custom_disable_theme_js' );
function custom_disable_theme_js() {
Fusion_Dynamic_JS::deregister_script('avada-comments');
Fusion_Dynamic_JS::deregister_script('avada-general-footer');
Fusion_Dynamic_JS::deregister_script('avada-mobile-image-hover');
Fusion_Dynamic_JS::deregister_script('avada-quantity');
Fusion_Dynamic_JS::deregister_script('avada-scrollspy');
Fusion_Dynamic_JS::deregister_script('avada-select');
@hmbashar
hmbashar / related-post.php
Created September 18, 2019 05:40
Query related post by category
<?php
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<ul>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php the_content('Read the rest of this entry &raquo;'); ?>
</li>
@hmbashar
hmbashar / author comments count.php
Created September 16, 2019 05:16
Get total number of comment of the posts written by an author
<?php
$args = array(
'post_author' => '' // fill in post author ID
);
$author_comments = get_comments($args);
echo count($author_comments);
?>