Skip to content

Instantly share code, notes, and snippets.

@oalansari82
oalansari82 / functions.php
Last active September 5, 2016 22:05
Language support in Genesis child themes
<?php
//* Do not include the opening php tag
// The below code will go into your functions.php right before "//* Start the engine"
// once done you need to upload your language files to child theme's /languages folder.
//Child Theme Language override
define('GENESIS_LANGUAGES_DIR', STYLESHEETPATH.'/languages');
define('GENESIS_LANGUAGES_URL', STYLESHEETPATH.'/languages');
@oalansari82
oalansari82 / functions.php
Last active October 27, 2016 17:14
Create YouTube Videos page using CPT, ACF and Featherlight
<?php
// Only include the code below this line
add_action( 'init', 'register_cpt_youtube_videos' );
/**
* Create YouTube videos custom post type
*/
function register_cpt_youtube_videos() {
$labels = array(
@oalansari82
oalansari82 / functions.php
Last active October 25, 2016 17:20
Add sources field in Genesis using ACF Pro
<?php
// Only include the code below this line
add_action( 'genesis_entry_footer', 'io_sources_custom_fields' );
/**
* Add sources to posts, if posts have sources assigned
*/
function io_sources_custom_fields() {
if ( is_singular( $post_types = 'post' ) ) {
<?php
/**
* This file adds a timeline to your desired page in Genesis Framework.
*
* @author Omar Al-Ansari
* @link http://www.alansari.io
*/
// Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
@oalansari82
oalansari82 / functions.php
Last active May 23, 2017 09:52
Google Map with Multiple Markers in Genesis using ACF Pro
<?php
add_action( 'init', 'register_cpt_locations' );
/**
* Create Locations custom post type
*/
function register_cpt_locations() {
$labels = array(
'name' => __( 'Locations', 'locations' ),
'singular_name' => __( 'Location', 'locations' ),
@oalansari82
oalansari82 / page-testimonials.php
Last active December 18, 2016 16:41
Create Testimonials using ACF Repeater
<?php
/* Template Name: Testimonials */
add_filter( 'body_class', 'io_body_class' );
/**
* Adds a css class to the body element
*
* @param array $classes the current body classes
* @return array $classes modified classes
@oalansari82
oalansari82 / single.php
Last active January 11, 2017 16:45
Create related posts section in Genesis Framework using ACF
<?php
add_action( 'genesis_before_comments', 'io_related_posts' );
function io_related_posts() {
$relatedPosts = get_field( 'related_posts' );
if( $relatedPosts ):
echo '<div class="related-posts-container">';
echo '<h3>Related Posts</h3>';
echo '<ul class="related-posts">';
@oalansari82
oalansari82 / home.php
Created January 26, 2017 14:35
Two Genesis Queries with pagination
<?php
add_action( 'genesis_after_header', 'io_news_featured_news_post' );
/**
* Outputs a custom loop with one features post
*
* @global mixed $paged current page number if paginated
* @return void
*/
function io_news_featured_news_post() {
@oalansari82
oalansari82 / functions.php
Last active February 2, 2017 17:26
WPML Language Selector Function
<?php
// WPML Language Selector
function io_language_selector( $english, $arabic ) {
if ( 'en' == ICL_LANGUAGE_CODE ) {
return $english;
}
elseif ( 'ar' == ICL_LANGUAGE_CODE ) {
return $arabic;
}
@oalansari82
oalansari82 / AppDelegate.swift
Created August 7, 2017 13:25
Transparent NavigationBar in Swift 3
// Add the below code in AppDelegate.swift inside of didFinishLaunchingWithOptions function
UINavigationBar.appearance().barTintColor = UIColor.white
UINavigationBar.appearance().isTranslucent = true
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)