Difference between revisions of "Week Twelve (MGDP2060)"
Karl Jones (Talk | contribs) |
Karl Jones (Talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
'''NO CLASS NEXT WEEK'''. Have a happy Thanksgiving. | '''NO CLASS NEXT WEEK'''. Have a happy Thanksgiving. | ||
+ | |||
+ | Previous: [[Week Eleven (MGDP2060)]] - Next: [[Week Thirteen (MGDP2060)]] | ||
+ | |||
+ | == PHP code for custom post type (p. 517) == | ||
+ | |||
+ | You need this code in your <code>functions.php</code> file, in order to display custom post type (such as Products): | ||
+ | |||
+ | <pre> | ||
+ | function add_product_to_archives ( $wp_query ){ | ||
+ | $types_array = array ( 'post', 'product'); | ||
+ | if ( is_archive() && empty ( $query->query_vars['suppress_filters']) ) { | ||
+ | set_query_var ('post_type', $types_array); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | add_action ( 'pre_get_posts', 'add_product_to_archives'); | ||
+ | </pre> | ||
+ | |||
+ | The code appears on page 517 of the textbook. | ||
+ | |||
+ | (1) Previously, I said that you could skip this step. This turns out to be not true: you do need to use this code in order for the <code>category.php</code> theme to work correctly. | ||
+ | |||
+ | (2) You can't have a second copy of the code, for a second custom post type -- if you do, the code will not work. | ||
+ | |||
+ | (2.a) There must be some other code which allows use of multiple custom post types, however, I don't have that code at this time. | ||
+ | |||
+ | == Contact form plugins for WordPress == | ||
+ | |||
+ | To implement [[Web form|web forms]] in WordPress, use a [[WordPress plugin|plugin]]. | ||
+ | |||
+ | Many are available. See: | ||
+ | |||
+ | * [http://www.wpbeginner.com/plugins/5-best-contact-form-plugins-for-wordpress-compared/ 5 Best Contact Form Plugins for WordPress Compared] | ||
+ | * [https://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/ 6 Best Contact Form Plugins for WordPress Compared (2016 Edition)] | ||
+ | |||
+ | I like [http://contactform7.com/ Contact Form 7] - see also [http://contactform7.com/docs/ Docs]. | ||
== Exercises == | == Exercises == |
Latest revision as of 14:53, 27 November 2016
This article lists topics for Week Twelve of Web Design and Development III (MGDP2060).
NO CLASS NEXT WEEK. Have a happy Thanksgiving.
Previous: Week Eleven (MGDP2060) - Next: Week Thirteen (MGDP2060)
PHP code for custom post type (p. 517)
You need this code in your functions.php
file, in order to display custom post type (such as Products):
function add_product_to_archives ( $wp_query ){ $types_array = array ( 'post', 'product'); if ( is_archive() && empty ( $query->query_vars['suppress_filters']) ) { set_query_var ('post_type', $types_array); } } add_action ( 'pre_get_posts', 'add_product_to_archives');
The code appears on page 517 of the textbook.
(1) Previously, I said that you could skip this step. This turns out to be not true: you do need to use this code in order for the category.php
theme to work correctly.
(2) You can't have a second copy of the code, for a second custom post type -- if you do, the code will not work.
(2.a) There must be some other code which allows use of multiple custom post types, however, I don't have that code at this time.
Contact form plugins for WordPress
To implement web forms in WordPress, use a plugin.
Many are available. See:
- 5 Best Contact Form Plugins for WordPress Compared
- 6 Best Contact Form Plugins for WordPress Compared (2016 Edition)
I like Contact Form 7 - see also Docs.