Skip to content

Instantly share code, notes, and snippets.

@alimoshen
alimoshen / scripts.js
Created April 6, 2018 11:43
Fancybox 3
$(".content img").on("click", function(){
$.fancybox.open ({
src : $(this).attr('src'),
type : 'image'
});
});
@alimoshen
alimoshen / taxonomy.php
Created March 12, 2018 14:29
Get Custom Taxonomy Term Data
<?php
$taxonomyTerm = get_terms(
'custom_taxonomy_name',
array(
'parent'=> 0,
'orderby' => 'date',
'hide_empty' => 0,
'number' => 3 //Number of items
)
);
@alimoshen
alimoshen / category.php
Last active March 12, 2018 14:25
Get Taxonomy Terms Data
<?php $categories = get_the_category();
echo $categories[0]->name; ?>
@alimoshen
alimoshen / post-type.php
Created January 29, 2018 23:21
Custom post type registration
// Post type 'expertise'
add_action( 'init', 'create_expertise_post_type', 4 );
function create_expertise_post_type()
{
$labels = array(
'name' => __( 'Expertise' ),
'singular_name' => __( 'Expertise' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Create New' ),
'edit' => __( 'Edit' ),
@alimoshen
alimoshen / .htaccess
Created January 30, 2018 22:01
HTTP to HTTPS via htaccess only
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
@alimoshen
alimoshen / functions.php
Created February 6, 2018 11:03
WordPress custom function display only child terms
function get_child_terms_function($postid=null,$taxonomy){
if ($postid === null)
return false;
$terms=wp_get_post_terms($postid,$taxonomy);
if($terms){
foreach ( $terms as $term ) {
if($term->parent!='0') $termarr[]=$term;
}
@alimoshen
alimoshen / functions.php
Created February 6, 2018 10:55
WordPress custom function display only parent terms
function get_parent_terms_function($postid=null,$taxonomy){
if ($postid === null)
return false;
$terms=wp_get_post_terms($postid,$taxonomy);
if($terms){
foreach ( $terms as $term ) {
if($term->parent=='0') $termarr[]=$term;
}
@alimoshen
alimoshen / index.html
Last active January 31, 2018 15:13
Index page
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=[YOUR-API-KEY-HERE]&callback=initMap" async defer></script>
@alimoshen
alimoshen / config.json
Created January 31, 2018 15:11
Google Map API Json file
[
{
"elementType": "geometry",
"stylers": [
{
"color": "#ebe3cd"
}
]
},
{
@alimoshen
alimoshen / script.js
Created January 31, 2018 15:09
Google Map API
function initMap() {
// Styles a map in night mode.
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.674, lng: -73.945},
zoom: 12,
styles:
[{
"elementType": "geometry",
"stylers": [
{