Exclude events, venues, organizers from inline link search

Home Forums Calendar Products Events Calendar PRO Exclude events, venues, organizers from inline link search

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1153410
    leonardchamber
    Participant

    This is hard to explain but … you know how wordpress has the inline link editor as of 4.5?

    When you go to add a link in the page or post editor, you start to type the page name and it automatically searches the pages for you, which is really handy except that we have a zillion events with names that are similar to a page we would like to link to. So, you get search results with nothing but “Library” -events- when you are looking for the “Library” page to link to.

    This page has a good animation of the inline link editor that shows what I am talking about – http://www.wpbeginner.com/news/whats-new-in-wordpress-4-5/

    I would rather just exclude TEC items from this search. It’s going to really confuse my users.

    Thanks!

    #1153457
    Nico
    Member

    Hi there,

    Thanks for getting in touch with us! Interesting question here πŸ™‚

    I’ve googled a bit and hopefully there’s a filter to modify this query! Try pasting the snippet below in your theme’s (or child theme’s) functions.php file:

    /* Tribe remove post types from editor link builder */
    function tribe_remove_post_types_from_link_builder( $query ) {

    // bail if the events calendar is not active
    if ( !class_exists( 'Tribe__Events__Main' ) ) return false;

    $remove_post_types = array(
    Tribe__Events__Main::POSTTYPE,
    Tribe__Events__Main::VENUE_POST_TYPE,
    Tribe__Events__Main::ORGANIZER_POST_TYPE
    );

    foreach( $remove_post_types as $post_type ) {

    $key = array_search( $post_type, $query['post_type'] );

    if( $key ) {
    unset( $query['post_type'][$key] );
    }
    }

    return $query;
    }
    add_filter( 'wp_link_query_args', 'tribe_remove_post_types_from_link_builder' );

    Please let me know if this works for you,
    Best,
    Nico

    #1155495
    leonardchamber
    Participant

    This reply is private.

    #1155767
    Nico
    Member

    You are welcome, no problem with the delay πŸ˜‰

    It’s seems to be a formatting issue, try pasting the snippet in a plain text editor before doing so in the functions.php file. Sometimes this helps, but if it doesn’t then try to remove the spaces/tabs and add those again.

    Also please note that you don’t need to add the PHP closing tag ?> to the end of the file, although I don’t think it causes this issue.

    Please give this a new try and let me know,
    Best,
    Nico

    #1155805
    leonardchamber
    Participant

    Funny, I thought I had pasted into Notepad prior to uploading, but there must have indeed been a formatting issue, because this time it worked fine. The multitudes of events no longer show up when trying to link something. Thank you!!

    #1155841
    Nico
    Member

    Wooot! Stocked to hear it works now πŸ™‚

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Exclude events, venues, organizers from inline link search’ is closed to new replies.