ACF Recent Posts Widget
ACFRPW adds a new widget to the Appearance -> Widgets -> ACF Recent Posts Widget. Most of the fields are quite obvious, you can choose from a set of settings to display the posts from. Each setting alters the amount and type of posts listed in the sidebar. Available Settings The widget supports the following settings: Widget Title Custom Widget container CSS class Option to ignore sticky posts Search keyword query Id based post exclusion Date Display, Date Modified, Relative and Custom Date Format specifiaction Listing posts from specific date period (start and end) Listing posts with specific password, listing password protected posts only or excluding these Post Type selection Post Formats selection Post Statuses selection Listing posts limited to author via author id Order specifiaction (ASC or DESC) Orderby specification (ID, Author, Title, Date, Modified, Random, Comment Count, Menu Order, Meta Value, Meta Value Numeric) Meta Key specifiaction (if Meta Value or Meta Value Numeric were chosen as orderby rule) Meta Comparison selection Meta Value Specification (for the Meta Comparison selection) Category limitation Tag limitation Id based custom taxonomy limitation Operator specifiaction for the above rules Number of posts to show Number of posts to skip Thumbnail display, thumbnail size (width, height), thumbnail alignment, default thumbnail Excerpt display, its word limit, its readmore text (occurs only if the amount of words exceeds the limit) Custom HTML to display before the loop Custom HTML to display after the loop Custom HTML to display before each posts. It supports custom meta keys and ACF fields Custom HTML to display after each posts. It supports custom meta keys and ACF fields Custom HTML to display for no posts found Custom and default CSS Custom HTML templates ACF supported fields The plugin has been tested with ACF 6 (Free and Pro). The plugin supports the following ACF fields: Text Textarea Number Email Password Wysiwg Editor Image File No other fields have been tested and are supported at the moment. Shortcode From version 4.4 the plugin supports shortcode embeds. Given the amount of options and their specific names (as in shortcode attributes) the shorcode builder has been introduced see 7th and 8th screenshots for the reference. You’ll see a popup once clicked on ACFRPW button which gives one an ability to automatically set up the shortcode code for you. The rest follows all of the options specified here. To use the shortcode one needs to have the WordPress editor enabled for the current page / post type. In case it was disabled (say via ACF) the button won’t appear. Creating Custom Templates From version 4.3 the plugin supports custom templates. To make usage of these one needs to make a copy of all the files found in the acf-recent-posts-widget/templates directory and copy them over to the active template directory to acfrpw subdirectory. The approach is similar to the way WooCommerce plugin works and has it’s drawbacks. With every new feature the files may be outdated. Similarly to the widget template files, a separate, custom markup can be created for the shortcode build post listing. Copy the acf-recent-posts-widget/template files to acfrpw-blog directory created inside your active theme directory. Template files There are 3 main template files: loop-after.php (which displays the markup after each of the posts and closes the markup container) loop-before.php (which displays the markup before each of the posts and opens the markup container) loop-inner.php (which is enqueued for each of the posts separatelly and contains the markup of every single post) Usage The usage is quite advanced hence each template file contains a quite detailed documentation on how to use it. First of all the template files mustn’t have the global variables removed. Each of these variables stores the widget settings, which are then used to generate the code. Second of all the variable names are unobvious, loop-inner.php template file contains a list of all the names used, which are then extracted and available as php variables. Different template per widget / sidebar The templates allow one to adjust the markup of each single widget. One needs first to verify the widget id used, which may then be referenced. The variable which stores the widget id is $acf_rpw_args[‘widget_id’]. Dumping the value in the template is the best way to find out which automatic id has been created for your widget. The best way to handle the templates is to learn from their code. My personal suggestion is to copy over the templates to the current theme and work directly on them, doing one change at a time. The templates require learning curve to use and there’s no single answer to everyones problem. Complex usage This section covers plugin complex usage for advanced user willing to have more control over the behavior of the plugin as well as explains uncommon functionalities. Using the HTML textarea fields These sections might not be obvious. The HTML or text before / after the whole loop setting is an area where you can specify custom HTML markup to be added before / after the whole posts list. The HTML or text before / after each post is an area where you can not only specify custom HTML, but you are also given an ability to print any meta key or certain ACF fields (see ACF supported fields) Meta Key Name / ACF Usage These fields need to be wrapped inside the {meta name} or {acf field_name} tags (which are similar to shortcodes). The plugin will then parse these fields and print their according value. Say we have a custom ACF field of type text, for which the Field Name is “text”. To print its value one has to use [acf text] inside the befoe / after each post textarea. A similar solution applies to the meta key. Meta Value Usage The Meta Value field supports an array of elements, so that all of the meta_compare parameters could be used. To do so, please specify the two parameters separated by semicolon, for instance: 1234;12345. The plugin will convert these into an array and apply the proper operation for the two. Whatsmore the [date] shortcode can be used here. It takes the timestamp paramater as an argument, which is required – the possible arguments are the same as for the function described here: http://php.net/manual/pl/function.strtotime.php. For instance [date +1 day] would generate the tomorrow date in “Ymd” format. This can be used with custom meta field date. Plugin Filters The are several filters that can be used to enchance the plugin programatically: ‘acf_rwp_query’ which gives one the ability to filter the query applied to each widget. ‘acp_rwp_before’ which gives on the ability to filter the Front End output of the plugin before each post. There are two hooks attached here already which allow usage of the [acf] and [meta] shortcodes. ‘acp_rwp_after’ which gives on the ability to filter the Front End output of the plugin after each post. There are two hooks attached here already which allow usage of the [acf] and [meta] shortcodes. ‘acf_meta_value’ which filters the meta_value query parameter. Check the acf_widget_widget file for the arguments and use cases. Dependencies ACF (optional) Widget Base Class (included) Shortcode popups generator (included) Other Online Demo Plugin site and Docs Plugin Development Survey Languages Supported English (default) Polish (since May 11 2015) French (since June 29 2015), by wolforg, standalone source Spanish (since July 30 2023)
Top keywords
- meta22×1.75%
- acf20×1.59%
- custom19×1.51%
- posts17×1.35%
- widget17×1.35%
- value12×0.96%
- fields11×0.88%
- html11×0.88%
- post11×0.88%
- template10×0.80%
- date9×0.72%
- display9×0.72%
Image Widget
Image Widget is a simple plugin that uses the native WordPress media manager to add image widgets to your site. Image Widget Features Responsive MU Compatible Handles image resizing and alignment Link the image Add title and description Versatile – all fields are optional Upload, link to external image, or select an image from your media collection Customize the look & feel with filter hooks or theme overrides Quality You Can Trust Image Widget is developed and maintained by The Events Calendar, the same folks behind The Events Calendar, Event Tickets, and a full suite of premium plugins. This plugin is actively supported by our team and contributions from community members. If you see a question in the forum you can help with or have a great idea and want to code it up or submit a patch, that would be awesome! Not only will we shower you with praise and thanks, it’s also a good way to get to know us and lead into options for paid work if you freelance. Pull Requests & Translations Check us out on GitHub to pull request changes. Translations can be submitted here on WordPress.org. Documentation The built in template can be overridden by files within your template. Default vs. Custom Templates The Image Widget comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called “image-widget” in your template directory and copy over the “views/widget.php” file. Edit the new file to your hearts content. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release. New in 3.2: You may now also use the “sp_template_image-widget_widget.php” filter to override the default template behavior for .php template files. Eg: if you wanted widget.php to reside in a folder called my-custom-templates/ and wanted it to be called my-custom-name.php: add_filter('sp_template_image-widget_widget.php', 'my_template_filter'); function my_template_filter($template) { return get_template_directory() . '/my-custom-templates/my-custom-name.php'; } Filters There are a number of filters in the code that will allow you to override data as you see fit. The best way to learn what filters are available is always by simply searching the code for ‘apply_filters’. But all the same, here are a few of the more essential filters: widget_title This is actually a pretty typical filter in widgets and is applied to the widget title. widget_text Another very typical widget filter that is applied to the description body text. This filter also takes 2 additional arguments for $args and $instance so that you can learn more about the specific widget instance in the process of filtering the content. image_widget_image_attachment_id Filters the attachment id of the image. Accepts additional $args and $instance arguments. image_widget_image_url Filters the url of the image displayed in the widget. Accepts additional $args and $instance arguments. THIS IS DEPRECATED AND WILL EVENTUALLY BE DELETED image_widget_image_width Filters the display width of the image. Accepts additional $args and $instance arguments. image_widget_image_height Filters the display height of the image. Accepts additional $args and $instance arguments. image_widget_image_maxwidth Filters the inline max-width style of the image. Hint: override this to use this in responsive designs 🙂 Accepts additional $args and $instance arguments. Return null to remove this css from the image output (defaults to ‘100%’). image_widget_image_maxheight Filters the inline max-height style of the image. Accepts additional $args and $instance arguments. Return null to remove this css from the image output (defaults to null) image_widget_image_size Filters the selected image ‘size’ corresponding to WordPress registered sizes. If this is set to ‘tribe_image_widget_custom’ then the width and height are used instead. Accepts additional $args and $instance arguments. image_widget_image_align Filters the display alignment of the image. Accepts additional $args and $instance arguments. image_widget_image_alt Filters the alt text of the image. Accepts additional $args and $instance arguments. image_widget_image_link Filters the url that the image links to. Accepts additional $args and $instance arguments. image_widget_image_link_target Filters the link target of the image link. Accepts additional $args and $instance arguments. image_widget_image_attributes Filters a list of image attributes used in the image output. Similar to ‘wp_get_attachment_image_attributes’ Accepts $instance arguments image_widget_link_attributes Filters a list of attributes used in the image link. Similar to ‘wp_get_attachment_image_attributes’ Accepts $instance arguments Have You Supported the Image Widget? If so, then THANK YOU! Also, feel free to add this line to your wp-config.php file to prevent the image widget from displaying a message after upgrades. define( ‘I_HAVE_SUPPORTED_THE_IMAGE_WIDGET’, true ); For more info on the philosophy here, check out our blog post