Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type:

add_action( 'init', 'register_cpt_foto' );

function register_cpt_foto() {

    $labels = array( 
        'name' => _x( 'Fotoalbums', 'foto' ),
        'singular_name' => _x( 'Fotoalbum', 'foto' ),
        'add_new' => _x( 'Nieuw fotoalbum', 'foto' ),
        'add_new_item' => _x( 'Voeg nieuw fotoalbum toe', 'foto' ),
        'edit_item' => _x( 'Bewerk fotoalbum', 'foto' ),
        'new_item' => _x( 'Nieuw fotoalbum', 'foto' ),
        'view_item' => _x( 'Bekijk fotoalbum', 'foto' ),
        'search_items' => _x( 'Zoek in fotoalbums', 'foto' ),
        'not_found' => _x( 'Geen fotoalbums gevonden', 'foto' ),
        'not_found_in_trash' => _x( 'Geen fotoalbums gevonden in de prullenmand', 'foto' ),
        'parent_item_colon' => _x( 'Parent foto:', 'foto' ),
        'menu_name' => _x( 'Foto\'s', 'foto' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => true,
        'description' => 'Het posttype dat alle fotoalbums verzorgt.',
        'supports' => array( 'title', 'editor', 'excerpt', 'comments', 'page-attributes' ),
        'taxonomies' => array( 'post_tag' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,


        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array(
            'slug' => 'fotos',
            'with_front' => false
        ),
        'capability_type' => 'post'
    );

    register_post_type( 'foto', $args );
}

Now, I am using a plugin called Facebook Photo Fetcher. You can fetch FB albums with a magic tag. You only have to post this as HTML:

<!--FBGallery 1234567890123456789 cols=4 max=16 swapHead=1 --><!--/FBGallery-->

When you save this post, it is converted to a complete post with all the images inserted etc. The problem is: the plugin doesn't seem to recognise this tag! Or maybe it is disabled for custom post types? I don't know, but it does absolutely nothing and I don't know why!

share|improve this question

3 Answers 3

up vote 0 down vote accepted

[Comment reposted as answer at request of OP author:]

Rather than deleting them, why don't you add your post_type to the if() statement:

//Don't process anything but POSTS and PAGES (i.e. no revisions)
if( $data['post_type'] != 'post' && $data['post_type'] != 'page' && $data['post_type'] != 'foto' )
    return $data;

As that comment in the code makes quite clear, without that statement, you'll be processing all the revisions as well which probably isn't what you want (considering that the plugin author disabled it).

(Also, "hacking" a plugin like this will only work until you need to update the plugin. Make sure to contact the plugin author and talk to them about supporting custom post types.)

share|improve this answer
    
Thanks again! ;) –  Bram Vanroy Oct 11 '12 at 6:12

This will work for any already registered custom post type

function tags_for_foto() {
    register_taxonomy_for_object_type('post_tag', 'foto');
}
add_action('init', 'tags_for_foto');
share|improve this answer

Found it: In facebook-photo-fetcher/_output_gallery.php delete lines 15 to 17. These ones:

//Don't process anything but POSTS and PAGES (i.e. no revisions)
if( $data['post_type'] != 'post' && $data['post_type'] != 'page')
    return $data;

And it should work!

share|improve this answer
2  
Rather than deleting them, why don't you add yours post_type to the if() statement. As that comment makes quite clear, now you'll be processing all the revisions as well which probably isn't what you want (considering that the plugin author disabled it). Also, "hacking" a plugin like this will only work until you need to update the plugin. Make sure to contact the plugin author and talk to them about supporting custom post types. –  mrwweb Oct 8 '12 at 21:39
    
Thanks, this is indeed very much easier and neater! If you post your comment as an answer, I'll mark that one as correct! –  Bram Vanroy Oct 10 '12 at 20:08
    
Glad I could help. Answer posted below. –  mrwweb Oct 10 '12 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.