true, 'has_archive' => true, 'label' => 'Artists', 'show_ui' => true, 'supports' => ['title', 'editor', 'thumbnail'], 'rewrite' => [ 'slug' => 'artists' ] ]; register_post_type('isl_artist', $args); register_taxonomy( 'isl_type', ['isl_artwork'], array( 'label' => __( 'Type' ), 'public' => true, 'hierarchical' => true, 'rewrite' => [ 'slug' => 'type' ] ) ); register_taxonomy( 'isl_feature', ['isl_artist'], array( 'label' => __( 'Feature' ), 'public' => true, 'hierarchical' => true, 'rewrite' => [ 'slug' => 'feature' ] ) ); $args = [ 'public' => true, 'has_archive' => true, 'label' => 'Artwork', 'show_ui' => true, 'supports' => ['title', 'editor', 'thumbnail'], 'rewrite' => [ 'slug' => 'artwork' ] ]; register_post_type('isl_artwork', $args); $args = [ 'public' => true, 'has_archive' => true, 'label' => 'Exhibitions', 'show_ui' => true, 'supports' => ['title', 'content', 'editor', 'thumbnail'], 'rewrite' => [ 'slug' => 'exhibition' ] ]; register_post_type('isl_event', $args); } add_action('init', 'isl_init'); function new_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more'); function isl_excerpt_length( $length ) { return 30; } add_filter( 'excerpt_length', 'isl_excerpt_length', 999 ); function get_post_thumbnail_url($id, $size = 'large') { $thumb_url = false; if( has_post_thumbnail($id) ) { $thumb_id = get_post_thumbnail_id($id); $thumb_url_array = wp_get_attachment_image_src($thumb_id, $size, true); $thumb_url = $thumb_url_array[0]; } return $thumb_url; } require_once('functions/admin.php'); function pr($d) { echo '
';
  var_dump($d);
  echo '
'; } function bidirectional_acf_update_value( $value, $post_id, $field ) { // vars $field_name = $field['name']; $field_key = $field['key']; $global_name = 'is_updating_' . $field_name; // bail early if this filter was triggered from the update_field() function called within the loop below // - this prevents an inifinte loop if( !empty($GLOBALS[ $global_name ]) ) return $value; // set global variable to avoid inifite loop // - could also remove_filter() then add_filter() again, but this is simpler $GLOBALS[ $global_name ] = 1; // loop over selected posts and add this $post_id if( is_array($value) ) { foreach( $value as $post_id2 ) { // load existing related posts $value2 = get_field($field_name, $post_id2, false); // allow for selected posts to not contain a value if( empty($value2) ) { $value2 = array(); } // bail early if the current $post_id is already found in selected post's $value2 if( in_array($post_id, $value2) ) continue; // append the current $post_id to the selected post's 'related_posts' value $value2[] = $post_id; // update the selected post's value (use field's key for performance) update_field($field_key, $value2, $post_id2); } } // find posts which have been removed $old_value = get_field($field_name, $post_id, false); if( is_array($old_value) ) { foreach( $old_value as $post_id2 ) { // bail early if this value has not been removed if( is_array($value) && in_array($post_id2, $value) ) continue; // load existing related posts $value2 = get_field($field_name, $post_id2, false); // bail early if no value if( empty($value2) ) continue; // find the position of $post_id within $value2 so we can remove it $pos = array_search($post_id, $value2); // remove unset( $value2[ $pos] ); // update the un-selected post's value (use field's key for performance) update_field($field_key, $value2, $post_id2); } } // reset global varibale to allow this filter to function as per normal $GLOBALS[ $global_name ] = 0; // return return $value; } // add_filter('acf/update_value/name=art', 'bidirectional_acf_update_value', 10, 3); // add_filter('acf/update_value/name=event', 'bidirectional_acf_update_value', 10, 3); add_action( 'admin_init', 'posts_order_wpse_91866' ); function posts_order_wpse_91866() { add_post_type_support( 'isl_artist', 'page-attributes' ); } // options if( function_exists('acf_add_options_page') ) { acf_add_options_page(array( 'page_title' => 'Theme General Settings', 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => false )); acf_add_options_sub_page(array( 'page_title' => 'Archive Pages', 'menu_title' => 'Archive Pages', 'parent_slug' => 'theme-general-settings', )); } // function order_by_surname ($orderby_statement) { // $orderby_statement = "RIGHT(post_title, LOCATE(' ', REVERSE(post_title)) - 1)"; // return $orderby_statement; // } // add_filter( 'posts_orderby', 'order_by_surname' ); add_filter( 'posts_orderby', function( $orderby, \WP_Query $q ) { if( 'isl_last_word' === $q->get( 'orderby' ) && $get_order = $q->get( 'order' ) ) { if( in_array( strtoupper( $get_order ), ['ASC', 'DESC'] ) ) { global $wpdb; $orderby = " SUBSTRING_INDEX( {$wpdb->posts}.post_title, ' ', -1 ) " . $get_order; } } return $orderby; }, PHP_INT_MAX, 2 ); function isl_mce_before_init( $settings ) { $custom_colours = ' "98002E", "Red", "347C2C", "Green", "000000", "Black", "A59687", "Grey"'; $settings['textcolor_map'] = '['.$custom_colours.']'; $settings['textcolor_rows'] = 1; return $settings; } add_filter( 'tiny_mce_before_init', 'isl_mce_before_init' ); ?>