Skip to content

Instantly share code, notes, and snippets.

@faisalhmohd
faisalhmohd / .htaccess
Last active December 23, 2015 17:17
Add www to urls and remove index.html/index.htm on urls
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . http://www.%{HTTP_HOST}%1 [R=301,NE,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule . http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
@faisalhmohd
faisalhmohd / readmore.js
Created June 3, 2016 08:43
Displaying snippet of content with Read More button
// .content containing paragraphs
var content = $('.content').html();
var contentArray = content.split("</p>");
// Displaying only the first paragraph
$('.content').html(contentArray[0]);
// Displaying the rest after clicking on .reademore
$('.readmore').click(function () {
$('.content').html(content);
$('.readmore').hide();
});
@faisalhmohd
faisalhmohd / loadmore.js
Last active June 3, 2016 08:49
Displaying N posts and load more button
var postSize = $(".posts div").size();
var postLimit = 8;
var postDisplay = 8;
var endPosts = false;
$('.posts div:lt('+postDisplay+')').show();
$('#loadmore').click(function () {
if (postDisplay + postLimit <= postSize) {
postDisplay += postLimit;
}
else {
@faisalhmohd
faisalhmohd / socialshare.php
Created June 3, 2016 09:51
Dynamic social sharing buttons for Wordpress Post Page
<ul class="social-nav">
<li class="twitter">
<a href="javascript:window.open('http://twitter.com/intent/tweet?status=<?php echo urlencode(get_the_title()); ?>+<?php echo wp_get_shortlink(); ?> via @StarCeramics','Sharing <?php echo get_the_title() ?> ','width=500,height=800')">
<i class="fa fa-twitter"></i>
</a>
</li>
<li class="facebook">
<a href="javascript:window.open('http://www.facebook.com/share.php?u=<?php echo get_permalink($ID); ?>&title=<?php echo urlencode(get_the_title()); ?>','Sharing <?php echo get_the_title() ?> ','width=500,height=800')">
<i class="fa fa-facebook"></i>
</a>
@faisalhmohd
faisalhmohd / functions.php
Last active June 7, 2016 12:09
[WordPress] New post type on dashboard menu
add_action( 'init', 'register_custom_post_type' );
function register_custom_post_type() {
register_post_type( 'member',
array(
'labels' => array(
'name' => __( 'Members' ),
'singular_name' => __( 'Member' ),
'add_new' => __( 'Add New Member' ),
'add_new_item' => __( 'Add New Member' ),
),
@faisalhmohd
faisalhmohd / page-thepage.php
Last active June 26, 2016 12:50
[Wordpress] Infinite Loop of Posts on Custom Static Page
<?php
$paged = $_GET['paged'];
$perpage = 15; // Choose the number of posts per loop
$args = array (
'pagination' => true,
'posts_per_page' => $perpage,
'post_type' => 'post',
'offset' => $paged*$perpage
);
@faisalhmohd
faisalhmohd / index.php
Created June 26, 2016 17:47
[Wordpress] Infinte loop on all posts page
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$perpage = 5;
$args = array (
'pagination' => true,
'posts_per_page' => $perpage,
'post_type' => 'post',
'paged' => $paged
);
@faisalhmohd
faisalhmohd / Dockerfile
Last active July 28, 2016 17:53
Dockerfile for NodeJS development
# Running on ubuntu:latest
FROM ubuntu
# Update and install NodeJS + NPM
RUN apt-get update
RUN apt-get install -y nodejs npm
# Creating symlink
RUN ln -s /usr/bin/nodejs /usr/bin/node
@faisalhmohd
faisalhmohd / keybase.md
Created July 12, 2016 07:16
My Keybase verification

Keybase proof

I hereby claim:

  • I am faisalhmohd on github.
  • I am mohdfaisal (https://keybase.io/mohdfaisal) on keybase.
  • I have a public key whose fingerprint is 042A A11E D2D7 BE9B FA2B B210 3E79 35BE C478 2F82

To claim this, I am signing this object:

@faisalhmohd
faisalhmohd / index.php
Last active July 19, 2016 14:30
Page Links on WordPress for Dynamic use
<?php $ID = 0; // Page ID to refer ?>
<a href="<?php echo get_page_link($ID); ?>">Page Name</a>