Extending Wordpress Bundle

Custom post type

Custom posts can extend the Post entity to add some preprocess or new functions,

in the /src folder, add an Entity folder, then create a new class for the post_type using Pascal case

namespace App\Entity;

use Metabolism\WordpressBundle\Entity\Post;

class Guide extends Post
{
  public $is_new;
    
  public function __construct($id = null)
  {
    parent::__construct($id);

    $this->is_new = true;
  }
}

Other entities

Menu, Comment, MenuItem, Product, Term and User can be extended by creating the same file in the /src/Entity folder.

Last updated