• Resolved Kuassar

    (@kuassar)


    Hello everyone. Im building a Shop for sell images, and all products have the same first part of title. Too work if i need to upload a lot of images…

    Its possible to add authomatically a title when i go to create a New product?

    The idea is: Products>add New product> in Page of add product show authomatically a default title first at all

    Its possible to do?

    Thanks for read!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think you mean this?

    function my_default_title_filter() {
        global $post_type;
        if ( $post_type == 'product' ) {
            return 'My Filtered Title';
        }
    }
    add_filter('default_title', 'my_default_title_filter');
    Thread Starter Kuassar

    (@kuassar)

    OMG crslz! Exactly this! When i add a new product, the first i see its “My filtered title” in title section haha. Its exactly this :O

    Thanks, really thanks ??

    You’re welcome!

    Just in case, improved & updated version of the above code (works faster and is less prone to errors)

    function my_default_title_filter( $post_title, $post ) {
        if ( $post->post_type == 'product' ) {
            $post_title = 'My Filtered Title';
        }
    
        return $post_title; 
    }
    add_filter( 'default_title', 'my_default_title_filter', 10, 2 ); 

    Can you mark this question as resolved?

    regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show always default title when add New product’ is closed to new replies.