Automatically If there are new Posts, Get the next one

WordPress

Trigger

It is triggered every time there is a new blog post.

  • You can apply only to posts that contain one or more specific tags.
  • You can apply only to posts that belong to one or more specific categories.


Information provided

When executed, this operation delivers the following data, which can be used in the same automatic task.

  • Tags

  • Post Id {{id}}

  • Title {{title}}

  • Post URL {{link}}

  • Categories {{categories}}

  • Slug {{slug}}

  • Tags {{tags}}

  • Image URL {{image}}

  • Excerpt {{excerpt}}

  • Featured Media Id {{featured_media_id}}


Frequently Asked Questions


How do I configure my WordPress to read and update post metadata?

You need to update the `functions.php` file in WordPress and include the following code to allow metadata to be updated via the API:

function expose_metadata() {
      register_rest_field(
           'post',
           'post_meta_fields',
           array(
                'get_callback' => 'callback_read_post_meta',
                'update_callback' => 'callback_update_post_meta',
                'schema' => null,
           )
      );
}

function callback_read_post_meta( $object ) {
      $post_id = $object['id'];
      return get_post_meta( $post_id );
}

function callback_update_post_meta( $meta_value, $object, $field_name ) {
      $post_id = $object->ID;

      if (!is_array( $meta_value ) ) {
           return new WP_Error( 'rest_invalid_param', __( 'El valor debe ser un array de campos de metadatos.' ), array( 'status' => 400 ) );
      }

      foreach ( $meta_value as $meta_key => $meta_value ) {
           update_post_meta( $post_id, sanitize_key( $meta_key ), sanitize_text_field( $meta_value ) );
      }
      return true;
}

add_action( 'rest_api_init', 'expose_metadata' );

Write us

By email or by Telegram.
Monday to Friday from 7 a.m. to 1 p.m. (Spain).

Let's talk

Choose day and time.
We share the screen and answer all your questions.