Skip to content

Instantly share code, notes, and snippets.

View alana-mullen's full-sized avatar

Alana Mullen alana-mullen

  • Preston, UK
View GitHub Profile
@alana-mullen
alana-mullen / function.php
Last active August 24, 2018 06:52
How to use Google's Organisation Logo Schema.org markup with WordPress Theme Logo
function mytheme_setup() {
add_theme_support('custom-logo');
}
add_action('after_setup_theme', 'mytheme_setup');
@alana-mullen
alana-mullen / app-icon-uiimageview.swift
Last active April 12, 2017 23:52
Use current iOS app icon with UIImageView in Swift 2 (Swift 3 example: https://gist.github.com/thewirelessguy/b0eba855c0307b47168be85291788746)
let primaryIconsDictionary = NSBundle.mainBundle().infoDictionary?["CFBundleIcons"]?["CFBundlePrimaryIcon"] as? NSDictionary
let iconFiles = primaryIconsDictionary!["CFBundleIconFiles"] as! NSArray
let lastIcon = iconFiles.lastObject as! NSString //last seems to be largest, use first for smallest
let theIcon = UIImage(named: lastIcon as String)
let iconImageView = UIImageView(image: theIcon)
@alana-mullen
alana-mullen / AndroidManifest.xml
Last active August 8, 2018 00:34
Setting up styles.xml and values-v21/styles.xml to use Material Design with AppCompat. Rename styles21.xml as styles.xml and place in your res/values-v21 folder (you may need to create a values-v21 folder if you don't already have one).
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.thewirelessguy.myappname" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@alana-mullen
alana-mullen / Detect the last post in the WordPress loop
Last active May 29, 2023 16:50
Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@alana-mullen
alana-mullen / functions.php
Created August 9, 2013 22:28
Removing Custom Post Types in WordPress. This example removes the Orbit Custom Post Type from the Cornerstone WordPress starter theme. You would include it the functions.php of your child theme.
<?php
add_action( 'after_setup_theme','remove_cornerstone_features', 100 );
function remove_cornerstone_features() {
remove_action( 'init', 'Orbit');
}
?>
@alana-mullen
alana-mullen / gist:5745760
Last active March 25, 2018 02:19
Display the title and thumbnail of child custom post types on the parent custom post type
<?php
$pageChildren = get_pages('child_of='.$post->ID."&echo=0&post_type=custompostypename");
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<a href="' . get_permalink($pageChild->ID) . '">';
$childimage = wp_get_attachment_image_src(get_post_thumbnail_id($pageChild->ID), 'thumbnail_size');
$childimagealttext = get_post_meta(get_post_thumbnail_id($pageChild->ID), '_wp_attachment_image_alt', true);
echo '<img src="'. $childimage['0'] . '" alt="' . $childimagealttext . '"/></a>';
echo '<p><a href="' . get_permalink($pageChild->ID) . '">'. $pageChild->post_title.'</a></p>';
}
@alana-mullen
alana-mullen / functions.php
Last active December 18, 2015 01:18
Disable the WordPress Admin Bar on mobiles but enable on desktops for logged in users
<?php
// Disable the admin bar on mobiles but enable on desktops
function cornerstone_show_admin_bar() {
if( wp_is_mobile() || !is_user_logged_in() ) {
return false;
} else {
return true;
}
}
@alana-mullen
alana-mullen / functions.php
Last active December 17, 2015 06:19
Adding support for Custom Post Types in the WordPress Jetpack REST API. The example adds support for the Custom Post Type named 'portfolio'. You would add this function to the functions.php in your theme or a plugin.
<?php
add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types');
function allow_my_post_types($allowed_post_types) {
$allowed_post_types[] = 'portfolio';
return $allowed_post_types;
}
?>