Skip to content

Instantly share code, notes, and snippets.

View Tsunamijaan's full-sized avatar

Tariqul Islam Tsunamijaan

  • Coder Team IT
  • Rajshahi, Bangladesh
View GitHub Profile
@Tsunamijaan
Tsunamijaan / Option tree demo theme option
Created January 5, 2019 09:49
Option tree demo theme option
<?php
add_action( 'admin_init', 'my_theme_custom_theme_options', 1 );
function my_theme_custom_theme_options() {
$saved_settings = get_option( 'option_tree_settings', array() );
@Tsunamijaan
Tsunamijaan / Homepage---Front page only conditional code wordpress
Created January 5, 2019 09:49
Homepage/Front page only conditional code wordpress
Homepage only data with default data ===============
<?php if( is_home() || is_front_page() ) : ?>
<!-- Homepage Only Code -->
<?php else : ?>
<!-- Other Page Code -->
@Tsunamijaan
Tsunamijaan / Infinite animated.css in Owl Carousel
Created January 5, 2019 09:48
Infinite animated.css in Owl Carousel
@Tsunamijaan
Tsunamijaan / Custom post query with pagination
Created January 5, 2019 09:47
Custom post query with pagination
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=6&post_type=posttype&orderby=menu_order&order=ASC'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php
@Tsunamijaan
Tsunamijaan / Dynamic bootstrap carousel bullets
Created January 5, 2019 09:46
Dynamic bootstrap carousel bullets
@Tsunamijaan
Tsunamijaan / Show all tags sorting by the number of post
Created January 5, 2019 09:46
Show all tags sorting by the number of post
<?php
$tags = get_terms( array("post_tag"), array("orderby"=>"count","order"=>"DESC"));
if ( !empty( $tags ) && !is_wp_error( $tags ) ) :
echo '<ul>';
foreach ( $tags as $tag ) :
echo '<li>' . $tag->name . '(' . $tag->count . ')</li>';
endforeach;
echo '</ul>';
endif;
?>
@Tsunamijaan
Tsunamijaan / Sticky header after scroll
Created January 5, 2019 09:25
Sticky header after scroll
$(window).scroll(function() {
if ($(window).scrollTop() > 100) {
$('.main_h').addClass('sticky');
} else {
$('.main_h').removeClass('sticky');
}
});
if you want to add stick menu on custom div scroll=====
@Tsunamijaan
Tsunamijaan / Copy-paste and mouse’s right button disabled
Created January 5, 2019 09:24
Copy-paste and mouse’s right button disabled
<script type="text/javascript">
<!--
var message="Copy Protected Enable";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
@Tsunamijaan
Tsunamijaan / Show author more post
Created January 5, 2019 09:23
Show author more post
Use in theme functions.php file================
function get_related_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
$output = '<ul>';
foreach ( $authors_posts as $authors_post ) {
$output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
}
@Tsunamijaan
Tsunamijaan / Redirect to custom page
Created January 5, 2019 09:22
Redirect to custom page
Redirect to custom page when user logged in==================
function login_redirect( $redirect_to, $request, $user ){
return home_url('custom-page-url-extension');
//Custom page url extension where want redirect
}