Skip to content

Instantly share code, notes, and snippets.

@bhubbard
Last active December 15, 2015 21:52
Show Gist options
  • Save bhubbard/0bbe7c98b9925c7e7b76 to your computer and use it in GitHub Desktop.
Save bhubbard/0bbe7c98b9925c7e7b76 to your computer and use it in GitHub Desktop.
<?php
// Always add idx tags to wrappers
add_filter ('the_content', 'idxbroker_add_idx_tags', 99);
function idxbroker_add_idx_tags($content) {
global $post;
$idxstart = '<div id="idxStart" style="display: none;"></div>';
$idxstop = '<div id="idxStop" style="display: none;"></div>';
if ( is_singular('idx-wrapper') ) {
$content = $content . $idxstart . $idxstop;
}
// Returns the content.
return $content;
}
<?php
// Hide Title for Dynamic Wrappers
add_filter ('the_title', 'idxbroker_wrapper_hide_title');
function idxbroker_wrapper_hide_title($title) {
if ( is_singular('idx-wrapper') ) {
return '';
}
return $title;
}
<?php
// Wrapper Title on Edit Screen
add_action( 'add_meta_boxes', 'idxbroker_dynamic_wrapper_metabox' );
function idxbroker_dynamic_wrapper_metabox()
{
add_meta_box( 'idx-wrapper-tags', 'IDX Broker Start & Stop Tags', 'idxbroker_tags_metabox', 'idx-wrapper', 'normal', 'high' );
}
function idxbroker_tags_metabox() {
echo 'You will need to make sure all dynamic wrappers output the IDX Broker Start & Stop Tags:';
echo '<pre><code><div id="idxStart" style="display: none;"></div><div id="idxStop" style="display: none;"></div></code></pre>';
}
<?php
// Update wrapper title
function idxbroker_wrapper_title( $title ){
$screen = get_current_screen();
if ( 'idx-wrapper' == $screen->post_type ) {
$title = 'Wrapper Title';
}
return $title;
}
add_filter( 'enter_title_here', 'idxbroker_wrapper_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment