【问题标题】:gmw from custom fields - frontend posting来自自定义字段的 gmw - 前端发布
【发布时间】:2015-08-15 09:11:50
【问题描述】:

我正在尝试从发布名为fiche_artiste 的自定义帖子类型的表单中完成 gmw 的地址字段。

我在自制插件中使用此代码:

function gmw_update_fiche_artiste_location( $pid ) {

// Si c'est une édition d'un Artiste existant
if ( false !== wp_is_post_revision( $pid ) )
    return;

// Vérifie la sauvegarde //
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
    return;
}

//Vérifie les droit de l'utilisateur
if ( !current_user_can( 'edit_post', $pid ) )
    return;

//Obtention de l'information du champs du formulaire "address"
$gmw_address = get_post_meta( $pid, 'address', true );

if ( empty( $address ) )
    return;

//Appel le fichier update-location.php
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );

//Verifie si la fonction existe
if ( !function_exists( 'gmw_pt_update_location' ) )
    return;

//Crée un array à passer à la fonction
$gmw_args = array(
        'post_id' => $pid, //Identifie le nouvelle article 
        'post_type' => 'fiche_artiste',
        'address' => $gmw_address // L'adresse récupérée du champs adress
);

//Appelle la fonction
gmw_pt_update_location( $gmw_args );
}
//Execute la fonction à la création/mise à jour de l'article
add_action( 'gmw_pt_after_location_updated', 'gmw_update_fiche_artiste_location' );

但它不起作用。我名为 address 的自定义字段已正确填写,但本地化后未填写。

【问题讨论】:

  • 如果您翻译这些 cmets 和/或删除对诊断此问题没有特别帮助的那些 cmets,这将对我们所有人都有帮助。

标签: wordpress post frontend


【解决方案1】:

删除

        'post_type' => 'fiche_artiste',// my custom post type

根据文档。

ID 是唯一的,无论帖子类型是什么。

【讨论】:

    【解决方案2】:

    真的很抱歉,实际上这段代码运行得很好! 我只需要从后端发布新帖子!再次抱歉。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多