English 中文(简体)
最新版本
原标题:Update elementor page from Wordpress API

我有问题更新了我的新闻稿文本,从《新闻稿》转播。

Currently I have pages created and edited with Gutenberg which I can edit from Postman by calling the API Wordpress

https://example/wp-json/wp/v2/pages/100 and passing a content as a parameter updates the entire page.

问题在于,如果我把其中任何一页放在了Elementor,并再次从Pierman那里援引,那么它就不再更新。

我拿不出粉碎的花.,我有穿透器的自由版本。

是否有任何人知道是否需要在电话中通过任何额外的参数,或者是否需要进行某种调整,以便用Elementor修改或创建的网页能够更新从Wordpress AP中做出的改动?

问题回答

为创建新网页,您可使用WPAP(POST /wp/v2/pages,并包括我寄给你的“template”领域。

部件储存网页内容、环境、科学、科学、科学、科学、科学、科学、科学、科学、科学、语言、语言、语言和语言。 更新这页所有需要做的,是用从第一次要求到适当的元件“关键”,更新“后元表”价值栏。 下面是各种元子——你可能希望包括以下关键价值的例子:_elementor_content,_elementor_sets,_elementor_cs, ...etc)在请求机构。

您可使用wpdb:update_dbmeth选择和更新右行。

稍后,如果需要,你可以使用同一终点更新任何网页,而无需输入新的模板或人工更新该网页。 仅凭需要一名Elementor JSON从头等到头盔,再向同一终点发出另一请求。

这方面的一个例子是,一个惯例是,允许你在气象局表中更新Elementor JSON。 确保打下 call,或者任何人都可以把你的网页内容贴上他们喜欢的东西。

// Register the custom endpoint
add_action(  rest_api_init , function () {
  register_rest_route(  your-namespace/v1 ,  /update-elementor-content , array(
     methods  =>  POST ,
     callback  =>  update_elementor_content ,
     permission_callback  =>  __return_true , // Adjust permission check as needed
  ));
});

// Callback function for the endpoint
function update_elementor_content( WP_REST_Request $request ) {
  $post_id = $request->get_param(  post_id  );
  $meta_key = $request->get_param(  meta_key  );
  $meta_value = $request->get_param(  meta_value  );

  // Validate data
  if ( empty( $post_id ) || empty( $meta_key ) || empty( $meta_value ) ) {
    return new WP_Error(  missing_data ,  Please provide all required data (post_id, meta_key, meta_value) , 400 );
  }

  global $wpdb;

  // Update wp_postmeta table
  $result = $wpdb->update( 
      $wpdb->postmeta, 
      array(  meta_value  => $meta_value ), 
      array(  post_id  => $post_id,  meta_key  => $meta_key ) 
  );

  if ( $result === false ) {
    return new WP_Error(  update_failed ,  Failed to update Elementor content , 500 );
  }

  // Success response
  return array(
     message  =>  Elementor content updated successfully ,
  );
}




相关问题
Wrap stray text in <p> tags

Wordpress issue.. how do I wrap stray text in P tags? Example: Before- <div class = "content"> <img src = "hello.jpg"/> <h1>Introduction</h1> Hello! this is ...

Using jQuery Plugins with Wordpress

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must ...

WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Why can t I properly style a blockquote in Wordpress?

On the design I just created for my website, I have a blockquote styled with two quote images using the span technique in css: blockquote { background-image: url(images/openquote.jpg); background-...

How does the WordPress <!--nextpage--> tag actually work?

What happens? I m guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can t seem to find any documentation on how the underlying <?php ...

Wordpress Plug-ins: How-to add custom URL Handles

I m trying to write a Wordpress Plug-in but can t seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will ...

热门标签