• Resolved paulzz3000

    (@paulzz3000)


    Hi
    I’ve been using your excellent plug-in for ages now. Superb!
    I’ve just come across a very useful plug-in that lets me put anything anywhere – Global Content Blocks. Very useful.
    I was wondering if there was a way of add the GCB posts to your menu?
    Many thanks
    Paul

    https://wordpress.org/plugins/wp-jump-menu/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author James Krill

    (@jkrill)

    I know that, for instance, with a plugin like Advanced Custom Fields, you can add those in there because they are a custom post type. Go to the Jump Menu settings page and look for the Global Content Blocks in the list of post types. If it’s not there, then it can’t be added to the jump menu.

    Plugin Author James Krill

    (@jkrill)

    So, turns out GCB are not post types… so I had to write a custom “plugin” plugin for WPJM that will load these into the menu.

    I’ll post it within the next 24 hours and update this thread. Cheers!

    Plugin Author James Krill

    (@jkrill)

    Hi paulzz3000,

    You’ll want to update to 3.3.1 – which I just released. There is now a filter at the beginning and end of the menu <select>… which means you can add <optgroup>s or <options>

    I downloaded the Global Content Blocks and set up the filter to display them… this *should* work. Try adding this to your theme’s functions folder, or you could add it as a plugin (if you’re familiar with setting up plugins):

    add_action( 'plugins_loaded', 'wpjm_gcb_add_filter' );
    
        if (!function_exists('wpjm_gcb_add_filter'))
        {
            function wpjm_gcb_add_filter( $wpjm_string )
            {
                add_filter( 'wpjm-filter-beginning-of-list', 'wpjm_gcb_filter' );
            }
        }
    
        if (!function_exists('wpjm_gcb_filter'))
        {
            function wpjm_gcb_filter( $wpjm_string ) {
    
                if (class_exists('gcb'))
                {
                    $entries = gcb::get_entries();
                    if (!empty($entries))
                    {
                        $wpjm_string .= '<optgroup label="Global Content Blocks">';
                        foreach($entries as $entry) {
                            $wpjm_string .= '<option value="' . admin_url() . 'options-general.php?page=global-content-blocks&view=update&edid=' . $entry['id'] . '" ' . ( ( isset($_GET['edid']) && ($entry['id'] == $_GET['edid'] ) )?'selected="selected"':'').'>' . $entry['name'] . '</option>';
                        }
                        $wpjm_string .= '</optgroup>';
                    }
    
                }
    
                return $wpjm_string;
    
            }
        }
    Plugin Author James Krill

    (@jkrill)

    So, notice in there the add_filter function… the first parameter is wpjm-filter-beginning-of-list change this to wpjm-filter-end-of-list if you want the global content blocks to appear at the end of the list.

    Unfortunately there’s no way to order them within the custom post types… beginning or end is the best I could do for now.

    Cheers.

    Thread Starter paulzz3000

    (@paulzz3000)

    Excellent stuff. Many thanks!

    Plugin Author James Krill

    (@jkrill)

    You’re welcome!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Compatibility with Global Content Blocks’ is closed to new replies.