Code snippets are a great way to extend and customize WordPress. On CodeWP, creating a code snippet is easy with the built-in code editor. Here's how to do it:
Accessing the Code Editor
There are a couple ways to access the code editor to start creating a new snippet:
From the dashboard, click on the mode (like PHP, JS, CSS) to instantly open the editor in that mode.
Click the "Create New" button in the top left and choose "New Snippet" after selecting a mode.
Configuring Your Workspace
Once in the code editor, you can configure your workspace:
Select a Project (optional) - Choose an existing project to categorize this snippet under.
Select a Mode - Choose the mode (PHP, JS, CSS, etc) you want to write the snippet in.
Select a Preset (optional) - Choose a preset to pre-populate common code.
Creating the Snippet
With your workspace configured, it's time to write the snippet:
Enter a prompt - Explain what you want the snippet to do, like "Make a shortcode that displays the date".
Submit the prompt - CodeWP will analyze the prompt and generate starter code in the editor.
Review and edit - Check the generated code and make any tweaks needed.
Add additional details in prompts - Enter more prompts to add complexity and details.
Exporting the Snippet
Once your snippet is complete, export it:
Copy the file contents to paste into a snippets plugin.
Download as a .php file to use in your theme/plugins.
For complex snippets with multiple files, download the zip file.
And that's it! With just a few prompts, you can easily generate a customized code snippet on CodeWP for extending WordPress. Let us know if you have any other questions!