Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Simon Gevcen

When creating a new line for products, modify the default values

When I create a new line for products (see screenshot), I am getting some default values which I need to be modified.

1) Product title should be empty, it shouldn’t display anything. Why? Because my client needs to encode about 1000 products, it would be too much of a waste of time to always have to delete the default title.

2) The status of the product should by default be “published” instead of “draft”

How can I change those default values ?
Thanks

4 months, 1 week ago
Stefan van den Dungen Gronovius
Developer

1) Unfortunately, when you create a new post (or Product) in WordPress without a title, WordPress adds the ‘(no title)’ as fallback if the post type is not allowed to have a empty title.

2) You can use the following hook to change that.
https://github.com/codepress/admin-columns-hooks/blob/master/acp-quick_add-saved.php

The snippet for the two questions above should be something like this:

add_action('acp/quick_add/saved', function ($id, AC\ListScreen $list_screen) {
    if ($list_screen instanceof AC\ListScreen\Post && $list_screen->get_post_type() === 'product') {
        wp_update_post([
            'ID'          => $id,
            'post_status' => 'publish',
            'post_tile' => '
        ]);
    }
}, 10, 2);

But like I said, even when you provide an empty string as title, WordPress will put it back to (no title).

4 months, 1 week ago
Simon Gevcen

Hello, thanks for your answer.

But your code seems not ok, on the line ‘post_title’ it gives an error.

4 months, 1 week ago
Simon Gevcen

I’ve adjusted like below, and now it works. Thanks.

add_action('acp/quick_add/saved', function ($id, AC\ListScreen $list_screen) {
    if ($list_screen instanceof AC\ListScreen\Post && $list_screen->get_post_type() === 'product') {
        wp_update_post([
            'ID'          => $id,
            'post_status' => 'publish',
            'post_tile' => 'Nouveau produit',
        ]);
    }
}, 10, 2);
4 months, 1 week ago
Simon Gevcen

Edit : it works for the ‘publish’ but it doesn’t work for the ‘nouveau produit’ as default title.

Why ? Screenshot.

4 months, 1 week ago
Simon Gevcen

Can you please remove the flag solved of this ticket?

I’m not able to change the default title
‘post_tile’ => ‘Nouveau produit’, doesn’t work

4 months, 1 week ago

You must be logged in to reply to this topic.