thingsym / custom-post-type-widgets

WordPress plugin 'Custom Post Type Widgets' adds default custom post type widgets.
https://wordpress.org/plugins/custom-post-type-widgets/
GNU General Public License v2.0
27 stars 14 forks source link
widgets wordpress wordpress-plugin

Introducing Custom Post Type Widgets

Custom Post Type Widgets plugin adds default custom post type widgets. You can filter by registered Custom Post Type or Taxonomy on widgets.

How do I use it?

  1. Download and unzip files. Or install Custom Post Type Widgets plugin using the WordPress plugin installer. In that case, skip 2.
  2. Upload "custom-post-type-widgets" to the "/wp-content/plugins/" directory.
  3. Activate the plugin through the 'Plugins' menu in WordPress.
  4. Adds widgets to a widget area and configure settings through the 'Widgets' menu in WordPress.
  5. Have fun!

IMPORTANT: By default, WordPress will not work Date-based permalinks of custom post type. Recommend that you install the plugin in order to edit the permalink, if you are using a Date-based permalinks.

And try the following: Custom Post Type Rewrite

Descriptions of Widgets

Recent Posts (Custom Post Type)

display a list of the most recent custom posts.

Archives (Custom Post Type)

display a list of archive links for each month that has custom posts.

Categories (Custom Post Type)

display a list of categories that has custom posts.

Calendar (Custom Post Type)

display a calendar of the current month.

Recent Comments (Custom Post Type)

display a list of the most recent comments.

Tag Cloud (Custom Post Type)

display a list of the top 45 that has used in a tag cloud.

Search (Custom Post Type)

A search form for your site.

Constants

Hooks

Custom Post Type Widgets has its own hooks.

Filter hooks

Action hooks

Frequently Asked Questions

404 error when clicking month link.

You may need to edit the permalink of custom post type.

By default, WordPress will not work Date-based permalinks of custom post type.

For example, a month link generates a link in a format like /<custom post type name>/date/YYYY/MM/, if you set Numeric in Common Settings in Permalink Settings.

The month link has the following two patterns depending on the Common Settings. But a link like below will not work.

Recommend that you install the plugin in order to edit the permalink, if you are using a Date-based permalinks by the Widget.

And try the following:

Custom Post Type Rewrite https://wordpress.org/plugins/custom-post-type-rewrite/

If you installed multiple plugins that can edit permalinks, the rewrite rules or permalinks may interfere.

In that case, you can disable the generation of permalinks by setting the following two constants in wp-config.php or the theme's function.php.

define( 'CUSTOM_POST_TYPE_WIDGETS_DISABLE_LINKS_ARCHIVE', true );
define( 'CUSTOM_POST_TYPE_WIDGETS_DISABLE_LINKS_CALENDAR', true );

Taxonomy select of Categories or Tags do not appear.

Check the setting of the hierarchical argument of the register_taxonomy function.

hierarchical
(boolean) (optional) Is this taxonomy hierarchical (have descendants) like categories or not hierarchical like tags.
Default: false

Reference: https://codex.wordpress.org/Function_Reference/register_taxonomy

By hierarchical option,

If false, use "Tag Cloud (Custom Post Type)" as tags.
If true, use "Categories (Custom Post Type)" as categories.

Search filter dose not work.

Check the setting of the exclude_from_search argument of the register_post_type function.

'exclude_from_search' (bool) Whether to exclude posts with this post type from front end search results. Default is the opposite value of $public.

Show featured image as a thumbnail.

You can use the action hook custom_post_type_widgets/recent_posts/widget/prepend to adding thumbnails.

Code sample is as follows:

function cptw_hooks_setup() {
  add_action( 'custom_post_type_widgets/recent_posts/widget/prepend', 'cptw_recent_posts_prepend', 10, 4 );
}
add_action( 'after_setup_theme', 'cptw_hooks_setup' );

function cptw_recent_posts_prepend( $widget_id, $posttype, $instance, $recent_post ) {
  if ( has_post_thumbnail( $recent_post ) ) {
    echo get_the_post_thumbnail( $recent_post );
  }
}

Insert the above code into functions.php in your theme.

WordPress Plugin Directory

Custom Post Type Widgets is hosted on the WordPress Plugin Directory.

https://wordpress.org/plugins/custom-post-type-widgets/

Support

If you have any trouble, you can use the forums or report bugs.

Contribution

Small patches and bug reports can be submitted a issue tracker in Github.

Translating a plugin takes a lot of time, effort, and patience. I really appreciate the hard work from these contributors.

If you have created or updated your own language pack, you can send gettext PO and MO files to author. I can bundle it into plugin.

You can also contribute by answering issues on the forums.

Patches and Bug Fixes

Forking on Github is another good way. You can send a pull request.

  1. Fork Custom Post Type Widgets from GitHub repository
  2. Create a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Create new Pull Request

Contribute guidlines

If you would like to contribute, here are some notes and guidlines.

Test Matrix

For operation compatibility between PHP version and WordPress version, see below Github Actions.

Changelog

Upgrade Notice

License

Licensed under GPLv2.