极品女神无套呻吟啪_亚洲成人免费影视_中文有码久久_eeusswww电影天堂国产_玖玖玖国产精品

行業(yè)新聞

    wordpress調(diào)用參數(shù)WordPress 更新帖子函數(shù) wp_update_post()

    2022-06-24    來源:www.bjcthy.com

    說明

    () 函數(shù)用于更新數(shù)據(jù)庫中的文章。

    為了保證功能正常運(yùn)行wordpress調(diào)用參數(shù),更新后的文章ID必須傳入

    如何使用

    例子

    在調(diào)用 ( ) 之前創(chuàng)建一個(gè)數(shù)組以傳遞必要的元素。與 () 不同的是wordpress調(diào)用參數(shù),這里只需要傳遞將要更新的文章編號(hào)和元素。元素名稱應(yīng)與數(shù)據(jù)庫中的名稱匹配。

    // 更新編號(hào)為37的文章
      $my_post = array();
      $my_post['ID'] = 37;
      $my_post['post_content'] = 'This is the updated content.';
    // Update the post into the database
      wp_update_post( $my_post );

    wordpress調(diào)用參數(shù)_wordpress 調(diào)用菜單_wordpress 標(biāo)簽調(diào)用

    類別

    類別需要作為整數(shù)數(shù)組傳遞,該數(shù)組應(yīng)與數(shù)據(jù)庫中的類別編號(hào)匹配。即使文章只屬于一個(gè)類別wordpress網(wǎng)站建設(shè),情況也應(yīng)該如此。

    函數(shù)參數(shù)

    $post (array) (可選) 可以表示可以構(gòu)成 post 元素的對(duì)象。這些元素應(yīng)該與數(shù)據(jù)庫表中的列名一一對(duì)應(yīng)。 ID(編號(hào))字段可以不填寫,使用此功能意義不大。

    默認(rèn):一個(gè)空數(shù)組

    返回值

    如果文章成功添加到數(shù)據(jù)庫wordpress做網(wǎng)站,則返回文章編號(hào)。否則返回 0.

    源文件

    () 在 wp-/post.php.

    /**
     * Update a post with new post data.
    

    wordpress調(diào)用參數(shù)_wordpress 調(diào)用菜單_wordpress 標(biāo)簽調(diào)用

    * * The date does not have to be set for drafts. You can set the date and it will * not be overridden. * * @since 1.0.0 * * @param array|object $postarr Post data. Arrays are expected to be escaped, objects are not. * @return int 0 on failure, Post ID on success. */ function wp_update_post($postarr = array()) { if ( is_object($postarr) ) { // non-escaped post was passed

    wordpress 標(biāo)簽調(diào)用_wordpress調(diào)用參數(shù)_wordpress 調(diào)用菜單

    $postarr = get_object_vars($postarr); $postarr = add_magic_quotes($postarr); } // First, get all of the original fields $post = wp_get_single_post($postarr['ID'], ARRAY_A); // Escape data pulled from DB. $post = add_magic_quotes($post); // Passed post category list overwrites existing category list if not empty. if ( isset($postarr['post_category']) && is_array($postarr['post_category'])

    wordpress 標(biāo)簽調(diào)用_wordpress調(diào)用參數(shù)_wordpress 調(diào)用菜單

    && 0 != count($postarr['post_category']) ) $post_cats = $postarr['post_category']; else $post_cats = $post['post_category']; // Drafts shouldn't be assigned a date unless explicitly done so by the user if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) $clear_date = true; else

    wordpress 標(biāo)簽調(diào)用_wordpress 調(diào)用菜單_wordpress調(diào)用參數(shù)

    $clear_date = false; // Merge old and new fields with new fields overwriting old ones. $postarr = array_merge($post, $postarr); $postarr['post_category'] = $post_cats; if ( $clear_date ) { $postarr['post_date'] = current_time('mysql'); $postarr['post_date_gmt'] = ''; } if ($postarr['post_type'] == 'attachment') return wp_insert_attachment($postarr); return wp_insert_post($postarr); }

    文章來自互聯(lián)網(wǎng),侵權(quán)請(qǐng)聯(lián)系刪除,文章闡述觀點(diǎn)來自文章出處,并不代表本站觀點(diǎn)。 www.bjcthy.com



X