5 User Snippets Every WordPress® Developer Needs in VSCode
User snippets are an essential part of the daily workflow for most developers using VSCode. For the unfamiliar, user snippets allow developers to write large amounts of code in one short word. VSCode uses JSON files for each programming language to manage any shortcuts that the developer wants to use. This can be accessed through VSCode by going to File > Preferences > User Snippets. For the snippets below, they can be added to the html.json file. Make sure to add the snippets within the parent {} bracket.
WordPress® Query
This snippet is the most useful snippet for WordPress® developers. Developers often need to write queries to get various pages or custom post types. The below snippet generates a full query with the loop with one simple word, query. The arguments can be changed for the query to meet whatever needs the developer requires. Bill Erickson’s WP Query page has a full list of arguments with notes on what everything does.
ACF Repeater
This snippet creates a repeater loop for any repeater custom fields accessible on the page. However, this only applies to sites that have Advanced Custom Fields Pro on their site.
WordPress® Content
The snippet below allows you to quickly add the title and content of the post.
Include Template
You’ll often find that you will need to create include files for code that is commonly used in various templates. To add those files into templates, you can use the “includeTemplate” prefix to quickly add them.
Page Id Conditional
This final snippet allows you to quickly create a conditional check to see if the current page ID is equal to a number.
About Us
Did you know more than 200 clients have worked with PaperStreet for more than 10 years?