WordPress Amazon插件:Amazon Product In a Post Shortcode Usage
WordPress shortcodes were introduced in WordPress version 2.5. A shortcode is basically a placeholder for content that you want to put in a specific spot in a page or post. The content is usually generated when the page/post is loaded on the front end by the viewer. Shortcodes make it very easy to add all sorts of advanced content without the need to know any programming and without needing to modify any theme or template code.
Anatomy of a Shortcode
A Shortcode is comprised of a few simple elements. The main thing you will notice is that a shortcode is placed in square brackets (). Inside the brackets you add the shortcode name and any attributes and values needed to produce the desired effect. The outcome depends on how the shortcode was programmed and the number of attributes can be zero (none) up to an unlimited number – again, depending on how it was programmed.
In its simplest form, a shortcode is just a name or word inside the brackets and nothing else, like so:
A shortcode can also contain a closing “tag” is you want to include text with the shortcode, like:
[shortcode]Put your content here[/shortcode]
Not all shortcodes use closing tags and not all of them allow content text, so check with the documentation when you use one for a specific plugin or theme.
Most shortcodes have multiple attributes that you can set if you want to have different outcomes when the content is generated. Attributes (also called “Parameters”) and their Value are entered in a “keyed pair” type manner, which is
attribute="value". The attributes allowed and their allowed value are all determined by the shortcode creator.
[shortcode title="shortcode title" text_color="red"]Your Content Here[/shortcode] or
[shortcode title="shortcode title" text_color="green"]
Once you know what attributes you can use and the acceptable values, you can add them to do whatever you want – again, depending on what they are for and how they are programmed.
The Amazon Product In a Post Plugin comes with several shortcodes for you to use. They each have their own set of allowed Attributes/Parameters. Click the name to see how to use each one:
The main Shortcode. You can also use “amazonproducts” all lowercase. This will output an entirely formatted Amazon product (the same as if you do not use a shortcode for your products).
A Shortcode specifically designed to make adding individual elements of an Amazon product. Can also use the singular “amazon-element”.
A Shortcode for displaying Amazon search results.
A Shortcode for displaying Amazon Prodcts in a Grid.