This function will replace all occurrences of “look-for-this-string” in page content function wb_replace_text($text) { $text = str_replace(‘look-for-this-string’, ‘replace-with-this-string’, $text); return $text; } add_filter(‘the_content’, ‘wb_replace_text’);
Category Archives: Functions
add_filter(‘style_loader_tag’, ‘flatsomeIconsPreloader’, 10, 2); function flatsomeIconsPreloader($html, $handle) { if( 0 != strpos( $html, ‘flatsome-icons’ ) ) { $html = str_replace( “rel=’stylesheet'”, “rel=’preload’ as=’style’ “, $html ); $html .= “”; } return $html; }
function my_shortcode() { $message = ‘Hello world!’; // Output needs to be return return $message; } // register shortcode add_shortcode(‘shortcodeNameToCall’, ‘my_shortcode’);
function wpdocs_register_meta_boxes() { add_meta_box( ‘meta-box-id’, __( ‘Backend Name’, ‘textdomain’ ), ‘wpdocs_my_display_callback’, ‘post_type’ ); } add_action( ‘add_meta_boxes’, ‘wpdocs_register_meta_boxes’ ); function wpdocs_my_display_callback( $post ) { // INPUT FIELDS GO HERE ?> <label>Year: <input type=”text” name=”inputName” value=”<?php echo get_post_meta(get_the_ID(), ‘meta_key’)[0]; ?>” /></label> <?php } /** * Save meta box content. * * @param int $post_id Post ID */ […]
add_action( ‘manage_colourmedia_column’, ‘colourmedia_columns’, 10, 2 ); function manage_colourmedia_columns( $column, $post_id ) { global $post; $terms = get_post_meta( $post_id ); switch( $column ) { case ‘thumbnail’ : $url = get_the_post_thumbnail_url($post_id); printf( ‘<img src=”‘.$url.'” style=”width:100px”/>’ ); break; case ‘city’ : printf($terms[‘City’][0]); break; case ‘category’ : $cat_list = wp_get_post_terms($post->ID, ‘category’, array(“fields” => “names”)); foreach($cat_list as &$category){ echo ‘<a […]
function reg_cat() { register_taxonomy_for_object_type(‘category’,’scr’); } add_action(‘init’, ‘reg_cat’);
add_filter( ‘manage_edit-colourmedia_columns’, ‘colourmedia_columns’ ) ; // init function function colourmedia_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘thumbnail’ => __( ‘Thumbnail’ ), ‘category’ => __( ‘Category’ ), ‘title’ => __( ‘Name’ ), ‘city’ => __( ‘City’ ), ‘featured’ => __( ‘Featured’ ), ); return $columns; }