WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom Field Template] wp-admin/edit.php & custom post (10 posts)

  1. sam05
    Member
    Posted 3 years ago #

    Hi,

    I have two problem to use CFT :

    First when the plugin is activated, I can't access the wp-admin/edit.php page, I always obtain a blank page wihtin nothing else.

    Then, I realized a template, it works well on posts. But when I want to use it with my custom post, it doesn't work. I can't see all my custom fields, and the name of the block is "Custom Field Template" than my template name.

    Any idea ? Thanks for anything, because I can't find any solutions about these two problems.

  2. sam05
    Member
    Posted 3 years ago #

    I successfully created my own Custom Post Type, from scratch, not using a plugin. It's for adding content about conference rooms
    register_post_type( 'gps_room',
    array(
    'labels' => array(
    'name' => __( 'Conference Rooms' ),
    'singular_name' => __( 'Conference Room' ),
    'add_new_item' => __( 'Add New Conference Room' ),
    bla bla bla
    Then I activated the Custom Field Template plugin but I can't get it work work with my new custom post type.
    In Settings > Custom Field Template...
    - when "Custom Post Type (comma-delimitated)" is empty, the custom fields show properly in Add New Post but not in Add New Conference Room
    - when I put gps-room in "Custom Post Type (comma-delimitated)", I see the Custom Field Template meta box on the Add New Conference Room page but it's empty except for two buttons "Initialize" and "Save." Neither of which seem to do anything when clicked.
    I feel like I'm close. I've got the meta box but not the fields. What am I missing?

  3. Hiroaki Miyashita
    Member
    Posted 3 years ago #

    You might mistype gps_room and gps-room. Please confirm it.

  4. sam05
    Member
    Posted 3 years ago #

    No, I checked that and it's the same value. I tried with other name in one word (like "professionnel") and I obtained the same result.

    And for my first problem, have you an idea ?

    I really need your help for both (which are independent), please.

  5. WebEndev
    Member
    Posted 3 years ago #

    Yes, I have spent a lot of time trying to get Custom Field Template to work with custom post types, and have not been successful.
    This would be a GREAT feature to get working.

  6. franxo
    Member
    Posted 3 years ago #

    - when I put gps-room in "Custom Post Type (comma-delimitated)", I see the Custom Field Template meta box on the Add New Conference Room page but it's empty except for two buttons "Initialize" and "Save." Neither of which seem to do anything when clicked.

    Same problem!

    My custom type post definition is:

    add_action( 'init', 'create_my_post_types' );
    
    function create_my_post_types() {
    	register_post_type( 'evento',
    		array(
    			'labels' => array(
    				'name' => __( 'Eventos' ),
    				'singular_name' => __( 'Evento' ),
    				'add_new' => __( 'Añadir nuevo' ),
    				'add_new_item' => __( 'Añadir Nuevo Evento' ),
    				'edit' => __( 'Editar' ),
    				'edit_item' => __( 'Editar Evento' ),
    				'new_item' => __( 'Nuevo Evento' ),
    				'view' => __( 'Ver Evento' ),
    				'view_item' => __( 'Ver Evento' ),
    				'search_items' => __( 'Buscar Evento' ),
    				'not_found' => __( 'No se han encontrado Eventos' ),
    				'not_found_in_trash' => __( 'No se han encontrado Eventos en la papelera' ),
    				'parent' => __( 'Padre del Evento' )
    
    			),
    			'description' => __( 'Evento es un tipo de Post creado para mostrar los eventos de la agenda' ),
    			'public' => true,
    			'show_ui' => true,
    			'publicly_queryable' => true,
    			'exclude_from_search' => false,
    			'menu_position' => 5,
    			'hierarchical' => true,
    			'query_var' => true,
    			'supports' => array( 'title', 'editor','comments','trackbacks','revisions','author', 'excerpt', 'custom-fields', 'thumbnail','page-attributes'),
    			'taxonomies' => array( 'post_tag', 'category'),
    			'can_export' => true,
    			'permalink_epmask' => EP_PERMALINK,
    
    		)
    	);
    }

    [EDIT] I'm using version 1.8.2

  7. franxo
    Member
    Posted 3 years ago #

    Hi, I SOLVED the problem !!!! :D:D:D:D:D:D

    I think is a problem with WP v3.0, I modify 2 lines in the file "custom-file-template.php"

    I don't now if this modifications are the best solution for the problem but it works for me.

    1 - In function "load_custom_field( $id = 0 )"

    Original code (line 1997 aprox):

    if ( $options['custom_fields'][$id]['post_type'] ) :
    
    			if ( substr($wp_version, 0, 3) < '3.0' ) :
    
    				if ( $options['custom_fields'][$id]['post_type'] == 'post' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php')) ) :
    
    					return;
    
    				endif;
    
    				if ( $options['custom_fields'][$id]['post_type'] == 'page' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php')) ) :
    
    					return;
    
    				endif;
    
    			else :
    
    				if ( $_REQUEST['post_type']!=$options['custom_fields'][$id]['post_type'] && $post->post_type!=$options['custom_fields'][$id]['post_type'] ) :
    
    					return;
    
    				endif;
    
    			endif;
    
    		endif;

    Modified code:

    if ( $options['custom_fields'][$id]['post_type'] ) :
    
    			if ( substr($wp_version, 0, 3) < '3.0' ) :
    
    				if ( $options['custom_fields'][$id]['post_type'] == 'post' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php')) ) :
    
    					return;
    
    				endif;
    
    				if ( $options['custom_fields'][$id]['post_type'] == 'page' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php')) ) :
    
    					return;
    
    				endif;
    
    			else :
    
    /*---------------------------> MODIFICIO  AQUI*/
    				if ( $_REQUEST['post_type']!=$options['custom_fields'][$id]['post_type'] && $post->post_type!=$options['custom_fields'][$id]['post_type'] && !($options['custom_fields'][$id]['custom_post_type'])) :
    
    					return;
    
    				endif;
    
    			endif;
    
    		endif;

    2 - In funcion "custom_field_template_filter()":

    Original code (line 2428 aprox):

    else :
    
    					if ( $post->post_type!=$options['custom_fields'][$i]['post_type'] ) :
    
    						continue;
    
    					endif;
    
    				endif;

    Modified code:

    else :
    
    /** ----------------------------------> MODIFICADO ESTO PARA QUE APAREZCA EL COMBO EN LOS TIPOS PERSONALIZADOS DE POSTS **/
    					if (( $post->post_type!=$options['custom_fields'][$i]['post_type'] )&&( !( $options['custom_fields'][$i]['custom_post_type'] ))) :
    						continue;
    
    					endif;
    
    				endif;

    I hope this help you too,

  8. sam05
    Member
    Posted 3 years ago #

    Yeaaaaah !!!

    It's working now ! You're THE BOSS ! I changed two lines that you specified and that's all right ;)

    Thanks a lot !

  9. sam05
    Member
    Posted 3 years ago #

    And it's working for me on 1.8.3 of CFT and 3.0.4 WP

  10. Prometeotdf
    Member
    Posted 3 years ago #

    You totally rock! Thank's = )

Topic Closed

This topic has been closed to new replies.

About this Topic