Templates to use multiple time within page?

New to WP, so this may be a newbie question.

My page will consist of structured data:
Movie title, Movie release date, Movie Poster Image filename.

On mediawiki, my page might look something like this:

{{movie-template|Gone With the Wind|1939|gwtw.jpg}}
{{movie-template|Citizen Kane|1941|ck.jpg}}
{{movie-template|Star Wars|1977|sw.jpg}}

How do I do this in wordpress?

Answers 1

  • If you are trying to do this within a page or post, you could make a shortcode out of it.

    [movie-template title="Gone With the Wind" date="1939" image="gwtw.jpg"] [movie-template title="Citizen Kane" date="1941" image="ck.jpg"] [movie-template title="Star Wars" date="1977" image="sw.jpg"]

    Then you need a little code, in your template's functions.php, or in a custom plugin:

    add_shortcode( 'movie-template', 'my_movie_listings' ); function my_movie_listings( $atts ) { $atts = shortcode_atts( array( 'foo_title' => 'title', 'foo_date' => 'date', 'foo_image' => 'image', ), $atts ); // $atts['foo_title'] is your movie title // $atts['foo_date'] is your movie date // $atts['foo_image'] is your movie image $ret = "do something here with {$atts['foo_title']}"; return $ret; }


Related Questions