json VS Code php Snippets

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json VS Code php Snippets相关的知识,希望对你有一定的参考价值。

{
	// Place your snippets for php here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"PHP open tag": {
		"prefix": "<?php ?>",
		"body": [
			"<?php ; ?>"
		],
		"description": "Habre php"
	},
	"Loop": {
		"prefix": "<?php wp_loop",
		"body": [
			"<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?>",
			"",
			"<?php endwhile; else : echo \"Aún no se ha publicado nada\"; endif; ?>"
		],
		"description": "Wordpress Loop"
	},
	"ACF rows": {
		"prefix": "<?php acf_rows",
		"body": [
			"<?php if( have_rows( '' ) ) : while( have_rows( '' ) ) : the_row( '' ); ?>",
			"",
			"<?php endwhile; endif; ?>"
		],
		"description": "ACF Rows"
	},
	"ACF Subfield": {
		"prefix": "<?php acf_subfield",
		"body": [
			"<?php the_sub_field( '' ); ?>",
		],
		"description": "ACF Subfield"
	},
	"ACF Field": {
		"prefix": "the_field",
		"body": [
			"the_field( '$1' ); ?>",
		],
		"description": "ACF Field"
	},
	"ACF Sub field": {
		"prefix": "the_sub_field",
		"body": [
			"the_sub_field( '$1' ); ?>",
		],
		"description": "ACF Sub field"
	},
	"WP Query": {
		"prefix": "<?php wp_query",
		"body": [
			"<?php ",
			"",
			"	\\$args = array(",
			"		'post_type'		=>	'$1',",
			"	);",
			"",
			"	\\$wp_query = new WP_Query( \\$args );"
			"",
			"?>",
			"",
			"<?php if( \\$wp_query->have_posts() ) : while( \\$wp_query->have_posts() ) : \\$wp_query->the_post(); ?>",
			"",
			"	$2",
			"",
			"<?php endwhile; endif; ?>"
		],
		"description": "The WP Query"
	},
}

以上是关于json VS Code php Snippets的主要内容,如果未能解决你的问题,请参考以下文章

VS Code配置snippets代码片段快速生成html模板,提高前端编写效率

text VS Code Slick Snippets

json Visual Studio代码的PowerShell代码段文件 - 放在〜\AppData \Roaming\Code \User \Snippets目录中

json 用于PHP和JavaScript的VS Code调试配置

json 在VS Code中以HTML格式展开PHP条件。

json 在VS Code中以HTML格式展开PHP条件。