![]() For template tidiness, start with adding this to your functions.I am an average PHP programmer, and I would like to create an image gallery on my website powered by one of my Dropbox image folders. You can of course use whatever markup you like to suit whichever way you want your images to display, but let me give you an example of code for your page template using the Flexslider jQuery plugin. Now all that remains is retrieving the slideshow images in your page template and display them. The above adds an extra field on your standard page editor pages where you can select a slideshow to associate with the page. Simple_fields_register_post_type_default('slideshow_page_connector', 'page') Simple_fields_register_post_connector('slideshow_page_connector', 'type_post_options' => array("enabled_post_types" => array("slideshows")) 'description' => 'Choose a slideshow to display on this page', How about adding a simple slideshow selector on the edit page? Start editing your functions.php file again and add the following: simple_fields_register_field_group('slideshow_page_options', We also need the ability to select which pages that should display which slideshow and then actually display the slideshows, right? No worries, Simple Fields gives us the tools to ease this part as well. However, it’s not time to lean back and enjoy just yet. It should look something like this:Īs you can see, we have all we need to create and manage slideshows as we see fit. The image field group is now associated with our slideshows post type, but there is one more thing we need to do in order to make the fields visible by default: simple_fields_register_post_type_default('slideshow_images_connector', 'slideshows') Īt this point, you should be able to go to your WordPress administrator pages, select edit or add a new slideshow and then see the repeatable file upload field that we just created. Again add to the functions.php file of your theme: simple_fields_register_post_connector('slideshow_images_connector', The next step is to connect the field group to our slideshows post type. 'description' => 'Add images to your slideshow here', To do this, we begin with registering a field group like this (still in the functions.php of your theme): simple_fields_register_field_group('slideshow_images', What we want is a repeatable file upload field attached to our slideshow posts so that we can freely add as many images we like to the slideshow. Although this can be done using the Simple Fields administration pages as described in the Simple Fields documentation, we’re going to show you how to do this in code. This because we intend to add and manage the content with our own custom fields instead of the standard content editor in wordpress. This creates a very basic custom post type which at this points has no content or attributes to edit besides the title. Add the following to the functions.php of your theme: register_post_type('slideshows', array( ![]() By utilizing the versatility of this plugin, we find ourselves in much less need of plugins for basic tasks like this.įirst off, let’s set up a custom post type for our slideshows. However, with experience comes the understanding of avoiding the use of too many plugins. Reinventing the wheel is perhaps useful for the beginner who wants to learn the inner workings of WordPress, everyone else usually goes for the first and best plugin that does the trick. That still leaves us with quite a few ways of going about it like plenty lines of code in your page template and/or the functions.php of your theme, or installing one of all the image slider/gallery plugins on. There are a thousand and one ways of doing this, but let’s narrow it down by saying that the editor wants to be able to create his/her own image slideshows and choose which set of images is to be displayed as a slideshow on which page. Imagine that you want to customize the look of one or more pages with an image slider. Instead, we want to show you the power and versatility of a plugin called Simple Fields. There are numerous WordPress plugins for creating image sliders/galleries out there, but this isn’t yet another how-to for using any of those.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |