Skip to content

Instantly share code, notes, and snippets.

View shahadat014's full-sized avatar

Md.Shahadat Hossen shahadat014

  • ACS TEXTILES BD LTD.
  • Rupganj, Narayanganj, Dhaka
  • 08:14 (UTC +06:00)
View GitHub Profile
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:04
Dynamic bootstrap carousel bullets
<?php
global $post;
$number = 0;
$args = array( 'posts_per_page' => -1, 'post_type'=> 'posttype', 'orderby' => 'menu_order', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li data-target="#myCarousel" data-slide-to="<?php echo $number++; ?>"></li>
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:05
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
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:07
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)
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:09
Get author post count inside & outside loop , Inside loop: First get user id, Then get post count in loop
$author_id= get_the_author_meta('ID');
echo count_user_posts( $author_id );
Outside loop
echo count_user_posts( 1 );
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:11
Redirecting to Another URL After contact form 7 submissions
On contact form 7 editor’s Additional Settings field section, just add this code.
on_sent_ok: "location = 'http://example.com/';"
#
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:12
logged conditional content WordPress
<?php if (is_user_logged_in() ): ?>
<a href="<?php echo wp_logout_url() ?>" title="Logout">Logout</a>
<?php else: ?>
<a href="http://example.com/wp-login.php" title="Logout">Member Login</a>
<?php endif ?>
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:13
Register widget in wordpress
function my_custom_theme_widgets() {
register_sidebar( array(
'name' => 'My Widget',
'id' => 'widget_id',
'before_widget' => '<div class="widget_div">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:15
Register custom post & custom taxonomy in wordpress
Register custom post type
add_action( 'init', 'my_theme_custom_post' );
function my_theme_custom_post() {
register_post_type( 'cpt',
array(
'labels' => array(
'name' => __( 'CPTs' ),
'singular_name' => __( 'CPT' )
),
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:19
Dynamic wordpress menu
Register wordpress menu
add_action('init', 'my_theme_register_menu');
function my_theme_register_menu() {
register_nav_menu( 'main-menu', 'Main Menu');
}
// Default menu
function my_theme_default_menu() {
@shahadat014
shahadat014 / wordpress code
Created January 18, 2015 19:21
How to add favicon in wordpress website?
Make sure you used this before </head>
If you have favicon as .ico format, you can use this code.
<link type="image/x-icon" rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/img/favicon.ico">
If you have favicon as png image format, you can use this code. Make sure your favicon size is 16x16px