I want to create a copy of the Post Title block to only display ‘n” number of words. I had posted a previous thread asking how to show only the first 2 words of a title. After much digging around, I thought the easiest (in comparison) method was to create a version of the Post Title block to do this instead of complicating things. Wherever I may require the full title, I can use the built-in Post Title block and where I feel I just need to showcase the first ‘n’ words, I can use the modified block.
I am a non developer. After digging through a lot of resources, I have installed WP Studio, VS Code and Node.js on my system. I presumed I could recreate the same src folder structure of the Post Title block (available on github) in VS Code and that would work. but i am getting errors, which is expected. (issues with package.json file among many). Maybe just recreating the files and folder structure isn’t the way to do this.
If I use the WP create-block method, it creates bunch of files required for a block but I am not sure how to add the files/code from the Post Title github src exactly so it creates the block I want.
Can someone guide me how I can use the Post-Title (or in future any other core block or any block for that matter) src files, make relevant modifications (for my current need I have used ChatGPT to enhance the function in the php file) and create a block of my own?
Thanks.
Prad G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.