Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Use Last Post for the Send Demo instead of Dummy Data #1

Open
gabriel-kaam opened this issue Jan 23, 2023 · 0 comments

Comments

@gabriel-kaam
Copy link

Hello there,

When I click on "Send Demo" ; it would be great if the data from the last Post were sent ; instead of Dummy Data ;

Capture d’écran

I wrote a little code that does just that, let me know if I can open a PR.

It's just a simple code that I wrote quickly ; we'll need to improve it a bit before we can merge ; but you get the idea.

<?php
// core/includes/integrations/wordpress/triggers/post_create.php

public function get_demo( $options = array() ) {
    $post = get_post(get_posts("post_type=post&numberposts=1&fields=ids")[0]);

    return [
        'post_id' => $post->ID,
        'post' => $post,
        'post_meta' => get_post_meta($post->ID),
        'post_thumbnail' => get_the_post_thumbnail_url($post, 'full'),
        'post_permalink' => get_permalink($post),
        'taxonomies' => wp_get_object_terms( $post->ID, 'category', [ 'fields' => 'slugs' ] ),
    ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant