Skip to content

Instantly share code, notes, and snippets.

View scripts.js
$(".content img").on("click", function(){
$.fancybox.open ({
src : $(this).attr('src'),
type : 'image'
});
});
@alimoshen
alimoshen / taxonomy.php
Created Mar 12, 2018
Get Custom Taxonomy Term Data
View taxonomy.php
<?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 Mar 12, 2018
Get Taxonomy Terms Data
View category.php
<?php $categories = get_the_category();
echo $categories[0]->name; ?>
@alimoshen
alimoshen / post-type.php
Created Jan 29, 2018
Custom post type registration
View post-type.php
// 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 Jan 30, 2018
HTTP to HTTPS via htaccess only
View .htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
@alimoshen
alimoshen / functions.php
Created Feb 6, 2018
WordPress custom function display only child terms
View functions.php
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 Feb 6, 2018
WordPress custom function display only parent terms
View functions.php
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;
}
View index.html
<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 Jan 31, 2018
Google Map API Json file
View config.json
[
{
"elementType": "geometry",
"stylers": [
{
"color": "#ebe3cd"
}
]
},
{
View script.js
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": [
{