Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / .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]