{"id":539,"date":"2016-08-15T14:02:09","date_gmt":"2016-08-15T12:02:09","guid":{"rendered":"https:\/\/www.nieuwsmarkt.nl\/?p=539"},"modified":"2017-10-01T09:09:57","modified_gmt":"2017-10-01T07:09:57","slug":"custom-post-types-and-custom-fields-within-beaver-builder","status":"publish","type":"post","link":"https:\/\/www.nieuwsmarkt.nl\/nl\/blog\/2016\/08\/15\/custom-post-types-and-custom-fields-within-beaver-builder\/","title":{"rendered":"Custom Post Types and Custom Fields within Beaver Builder"},"content":{"rendered":"<p><strong>CPT and CF have been in WordPress already for a long time. It gives WP developers the power to turn\u00a0WordPress into a full Content Management System. Not all aspects were that easy as just creating posts and pages. That will change.<\/strong><!--more--><\/p>\n<p><em>\u2022 Read all the comments via\u00a0the <a href=\"https:\/\/www.facebook.com\/groups\/beaverbuilders\/permalink\/643194979173188\/\" target=\"_blank\">Beaver Builder facebook group<br \/>\n<\/a>\u2022 Also follow <a href=\"https:\/\/www.facebook.com\/groups\/beaverbuilders\/648234702002549\/\" target=\"_blank\">this subject on Toolset<\/a> on the Beaver Builder facebook group<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-547\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/Records_and_Fields.jpg\" alt=\"Records_and_Fields\" width=\"450\" height=\"182\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/Records_and_Fields.jpg 744w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/Records_and_Fields-300x121.jpg 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/>First the basics of database publishing. WordPress on its own is based on a database, created in MySQL. The WordPress database consists of many so called tables in which content will be\u00a0stored in what they call records. A post is a record of a specific content type. Also the menu will be\u00a0stored in a specific table.<\/p>\n<p>A record consist of fields. Fields are the base of every cell in a records. The title of a blogpost is a field, so is the body of a blogpost. Categories and tags are also fields, called metadata fields, their content says something about the main purpose of the record, defined\u00a0bij keywords.<\/p>\n<h3>Custom Post Types<\/h3>\n<p>Without even knowing it, your website might already use so called <a href=\"https:\/\/codex.wordpress.org\/Post_Types\" target=\"_blank\">Custom Post Types<\/a> (CPTs). These types (recordtypes) do serve some special purposes. A webshop like WooCommerce uses a CPT for defining products\/services. Those records consist of extra fields compared to normal posts. For example price of a product, stock of a product, delivery time of a product etc. An event manager uses a CPT for managing events, the fields\u00a0could exist of booking data, location of an event, date of an event etc.<\/p>\n<p>In more advanced situations tabels are related with each other. You might have a table\u00a0with records containing fields with data about yourself, like name, address, bank account number\u00a0etc. Another table might contain your financial transactions like for online banking. The connections between the two tabels is done by your name or by your bank account nummer, which are unique fields, called index fields.<\/p>\n<h3>Tools within WordPress<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-548\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/generatewp.png\" alt=\"generatewp\" width=\"250\" height=\"50\" \/>Creating CPTs can be done in many ways with various plugins. The advantage is that you get a smooth user interface to define the various parameters to create the CPT. In most cases the disadvantage is that you need to keep that plugin activated to keep the CPT alive in your WordPress environment. If you don&#8217;t want the use of a plugin, you can create the CPT within the functions.php file within your childtheme. <a href=\"https:\/\/generatewp.com\/post-type\/\" target=\"_blank\">GenerateWP<\/a> offerst a nice user interface to let the code generate for you, based on the CPT parameters you request. Take the time to learn the various parameters, they effect the way the CPT works and used in your back-end. Also the use of taxonomies (like categories and tags in posts) can be generated together with the creation of the CPT.<\/p>\n<blockquote><p>There are many plugins for creating\u00a0CPTs, after a while you will prefer to code the creation of a CPT in the functions.php file of your childtheme<\/p><\/blockquote>\n<h3>Fields<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-549\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/acf-pro.jpg\" alt=\"acf-pro\" width=\"181\" height=\"73\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/acf-pro.jpg 316w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/acf-pro-300x121.jpg 300w\" sizes=\"auto, (max-width: 181px) 100vw, 181px\" \/>The standard CPT gets in base the titel field\u00a0and the bodytext field, all other fields you might want, must be created in some way. <a href=\"https:\/\/codex.wordpress.org\/Custom_Fields\" target=\"_blank\">WordPress<\/a> offers this, but in practical situations it is not interactive enough. A plugin might help improve the speed of development and the flexibility of the fieldtypes. One plugin, well know for the ease of use in creating fields is <a href=\"https:\/\/www.advancedcustomfields.com\/pro\/\" target=\"_blank\">Advanced Custom Fields (pro)<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-550\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/08\/toolset-logo-72.png\" alt=\"toolset-logo-72\" width=\"72\" height=\"86\" \/>However although the plugin lets you create fields very easily, you still need to write your own template files to either display archive or single CPT content, with the fields in it. That step requires more than average PHP knowledge to get the job done. Another plugin &#8216;<a href=\"https:\/\/wp-types.com\/\" target=\"_blank\">Types &amp; Views<\/a>&#8216; helps to improve the creation of templates without the need to program.<\/p>\n<blockquote><p>ACF (pro) also alows\u00a0the use of shortcodes to display content for &#8216;simple&#8217; fields<\/p><\/blockquote>\n<h3>Beaver Builder<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-319\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2016\/07\/beaver-builder-logo-150x150.jpg\" alt=\"beaver-builder-logo-150x150\" width=\"150\" height=\"150\" \/>Pagebuilders in general work with rows and columns. Each row can consits of one or more columns (content blocks). These blocks can contain various elements like title, plain text, images, sliders, interactive elements\/effects etc. Beaver Builder had the possibility to create templates, that is powerful in combination with CPT\/CFs.<\/p>\n<p>In Beaver Builder a template can be assigned to a CPT, which can hold various CFs. The challenge is to get the fields in the content blocks.<\/p>\n<p>One of the first steps was done by <a href=\"https:\/\/www.youtube.com\/watch?v=tDb1BZpR-eY\" target=\"_blank\">Robert Turner<\/a>, who used the ACF shortcodes together with the &#8216;<a href=\"https:\/\/wordpress.org\/plugins\/code-php-in-widget\/\" target=\"_blank\">Code PHP in Widget<\/a>&#8216; plugin. The shortcodes which can be used in ACF are limited to some simple fieldtypes like text etc.. For an image &#8216;real&#8217; PHP should be used. The Code PHP in Widget plugin show\u00a0that widget box in the modules overview of the WordPress widgets, which can be used in Beaver Builder. Inserting the right PHP code will do the job.<\/p>\n<p>Robert showed a nice example and the potential to use CFs within Beaver Builder. His example was &#8216;page based&#8217; and could be taken a step further with the use of Beaver Builder templates and use it within a CPT\/CFs.<\/p>\n<h3>Two developments<\/h3>\n<p>Two developers within the <a href=\"https:\/\/www.facebook.com\/groups\/beaverbuilders\/\" target=\"_blank\">Beaver Builder facebook group<\/a> are developing solutions for using the CPT\/CT combination together with templates:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=bkdiiI2k3Kw\" target=\"_blank\">Didou Schol<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=fg07d6sKRFY\" target=\"_blank\">Thierry Pigot<\/a><\/li>\n<\/ul>\n<p>The two solutions use the template concept over Beaver Builder. The solution from Didou is just a little bit further. Existing fieldnames appear in a pulldown list, you don&#8217;t need to know them and to type them in. And he also created a template for an archive page of CPT records, with their own set of fields to be displayed. Both solutions are very &#8216;light weight&#8217; compared to (for example) \u00a0&#8216;<a href=\"https:\/\/wp-types.com\/2016\/08\/toolset-2-2-adds-beaver-builder-integration-relevanssi-integration-new-layouts-cells-permission-based-access-control\/\" target=\"_blank\">Types&amp;Views<\/a>&#8216;.<\/p>\n<blockquote><p>Because of their businessmodel they force you to buy the whole package, the Views plugin is needed to make the connection. Types should be enought, because there the CPTS\/CF&#8217;s can be made and Beaver Builder plugin could take care of all &#8216;display work&#8217;.<\/p><\/blockquote>\n<p><a href=\"http:\/\/screencast-o-matic.com\/watch\/cDjonCiMCg\" target=\"_blank\">Diane Louise<\/a> posted a simular principe of displaying fields in Beaver Builder using the Types&amp;Views plugin.<\/p>\n<h3>Wrap it up<\/h3>\n<p>Using CPTs and CFs together with Beaver Builder opens a very nice perspective on how to use WP\/BB as a creatively designed content management system. Although not that complex in term of field relations between tables, but many &#8216;simple to use&#8217; applications could be build and used so much easier than before.<\/p>","protected":false},"excerpt":{"rendered":"<p>CPT and CF have been in WordPress already for a long time. It gives WP developers the power to turn WordPress into a full Content Management System. Not all aspects were that easy as just creating posts and pages. That will change.<\/p>","protected":false},"author":2,"featured_media":551,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4],"tags":[34,33,32,35],"class_list":["post-539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-review","tag-acf-pro","tag-cf","tag-cpt","tag-typesviews"],"_links":{"self":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":3,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/539\/revisions\/579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media\/551"}],"wp:attachment":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}