[wordpress插件] Category Posts in Custom Menu自定义菜单中的类别帖子

wordpress 插件 文章 2020-03-18 14:20 494 0 全屏看文

AI助手支持GPT4.0

评分
98
描述

The custom menu only allows adding a link that leads to a list of posts and pages belonging to a taxonomy (category, tag, etc).

自定义菜单仅允许添加链接,该链接指向属于分类法(类别,标签等)的帖子和页面列表。

If you want to list the posts and pages themselves and if you want WordPress to do this automatically for you, then I hope you will find this plugin useful.

如果您希望自己列出帖子和页面,并且希望WordPress自动为您执行此操作,那么我希望您会发现此插件有用。

Also works for custom taxonomies and custom post types!

也适用于自定义分类法和自定义帖子类型!

PHP 7.0 compatible

兼容PHP 7.0

Using it

使用

Enable the plugin and go to Appearance > Menus.

启用该插件,然后转到外观>菜单。

Create your Custom Menu.

创建您的自定义菜单。

Add a taxonomy (category/tag/custom) to the menu.

在菜单中添加分类法(类别/标签/自定义)。

Next, you can choose if you would like to replace the original link (to a page that lists the items) by the posts and pages themselves.

接下来,您可以选择是否要用帖子和页面本身替换原始链接(到列出项目的页面)。

For each Category or Post Tag item in the menu, you now have the following extra configuration options:

对于菜单中的每个“类别”或“帖子标签”项目,现在都有以下额外的配置选项:

    • replace the link by a list of posts in the menu y;

    • 通过菜单y / n中的帖子列表替换链接;

    • specify the (maximum) number of posts you want to show for this item (-1 = all, 0 also allowed now);
    • 指定要为此项目显示的(最大)帖子数(-1 =全部,现在也允许0);

    • their ordering ascending or descending by ID, Author, Title and other properties.

    • 其按ID,作者,标题和其他属性的升序或降序。

      See ‘Other Notes > Ordering’;

    • 请参阅“其他说明>订购”;

    • keep or remove the original menu item (always / only if there are no posts / never);
    • 保留或删除原始菜单项(始终/仅当没有帖子时/永不);

    • specify the title for the menu items.

    • 指定菜单项的标题。

      For this you can use %post_title, %post_author and other wildcards, see ‘Other Notes > Wildcards’.

    • 为此,您可以使用%post_title,%post_author和其他通配符,请参阅“其他说明>通配符”。

    Details

    详细信息

    This plugin uses the wp_nav_menu_objects filter hook to remove and replace category items in the menu by the posts in that category.

    此插件使用wp_nav_menu_objects过滤器挂钩删除菜单中的类别项,并用该类别中的帖子替换。

    It extends Walker_Nav_Menu_Edit to add input fields to Appearance > Menus and adds some CSS to style this properly.

    它扩展了Walker_Nav_Menu_Edit,以将输入字段添加到“外观”>“菜单”,并添​​加一些CSS来正确设置样式。

    The plugin now supports the wp_nav_menu_item_custom_fields hook and should be compatible with other plugins that also use this hook.

    该插件现在支持wp_nav_menu_item_custom_fields挂钩,并且应该与也使用此挂钩的其他插件兼容。

    Wildcards

    通配符

    You can control the title of the menu items generated by the plug-in with the following wildcards:

    您可以使用以下通配符控制由插件生成的菜单项的标题:

      • %post_title
      • %post_title

      • %post_author
      • %post_author

      • %post_featured_image_url
      • %post_featured_image_url

      • %post_featured_image (insers an HTML ‘img’ tag with the featured image or nothing if there is none)
      • %post_featured_image(插入带有特征图像的HTML'img'标签,如果没有则为空)

      • %post_featured_image_thumb_url
      • %post_featured_image_thumb_url

      • %post_featured_image_thumb (insers an HTML ‘img’ tag with the featured image thumbnail or nothing if there is none)
      • %post_featured_image_thumb(插入带有特征图像缩略图的HTML'img'标签,如果没有,则不添加标签)

      • %post_excerpt
      • %post_excerpt

      • %post_url
      • %post_url

      • %post_date for the unformatted post date: 2012-11-10 18:14:23
      • %post_date为未格式化的发布日期:2012-11-10 18:14:23

      • %post_date() for a formatted post date with the following default formatting: November 10th, 2012
      • %post_date()表示采用以下默认格式的带格式发布日期:2012年11月10日

      • %post_date() for custom date formatting.

      • %post_date(<此处为您的格式>)用于自定义日期格式。

        Example: %post_date(l jS \of F Y, h:i:s A).

        示例:%post_date(FY的ljS \,h:i:s A)。

        See https://codex.wordpress.org/Formatting_Date_and_Time for formatting options.

      • 有关格式设置选项,请参见 https://codex.wordpress.org/Formatting_Date_and_Time

      • %post_date_gmt
      • %post_date_gmt

      • %post_date_gmt()
      • %post_date_gmt()

      • %post_date_gmt()
      • %post_date_gmt(<此处为您的格式>)

      • %post_status
      • %post_status

      • %post_modified
      • %post_modified

      • %post_modified()
      • %post_modified()

      • %post_modified()
      • %post_modified(<您的格式此处>)

      • %post_modified_gmt
      • %post_modified_gmt

      • %post_modified_gmt()
      • %post_modified_gmt()

      • %post_modified_gmt()
      • %post_modified_gmt(<此处为您的格式>)

      • %post_comment_count
      • %post_comment_count

      • wildcards for custom fields, like %post_my_field, where ‘my field’ or ‘my_field’ is a custom field
      • 用于自定义字段的通配符,例如%post_my_field,其中“我的字段”或“ my_field”是自定义字段

      The following wildcards are deprecated:

      不推荐使用以下通配符:

        • %post_feat_image (url only)
        • %post_feat_image(仅URL)

        • %post_feat_image_thumb (url only)
        • %post_feat_image_thumb(仅URL)

        Ordering

        订购

        You can control the ordering of the items in the menu by sorting ascending or descending on the following properties:

        您可以通过对以下属性进行升序或降序排序来控制菜单中各项的顺序:

          • None
          • 没有

          • ID
          • ID

          • Author
          • 作者

          • Title
          • 标题

          • Date
          • 日期

          • Last Modified
          • 最后修改

          • Post/Page parent ID
          • 帖子/页面的父ID

          • Random Order
          • 随机顺序

          • Number of Comments
          • 评论数

          • Menu Order – Ordering by menu order is only possible for hierarchical types, such as pages.

          • 菜单顺序–按菜单顺序排序仅适用于分层类型,例如页面。

            These have the ‘Order’ option when editing, this is the menu order.

          • 这些在编辑时具有“订单”选项,这是菜单顺序。

          Extend the plugin

          扩展插件

          The plugin behavior can be extended.

          可以扩展插件的行为。

          To extend the backend with your own controls and use them in the posts query, add the following:

          要使用您自己的控件扩展后端并在帖子查询中使用它们,请添加以下内容:

            • Action “cpcm_custom_fields”: Use this to extend the custom fields to add to the Category Posts in Custom Menu container in Appearance > Menus
            • 动作“ cpcm_custom_fields”:使用它来扩展自定义字段,以添加到“外观”>“菜单”中“自定义菜单”容器中的“类别帖子”

            • Filter “cpcm_filter_posts_query”: This filter is called when the menu_item is of taxonomy type and the “Create submenu containing links to posts in this category” is checked.

            • 过滤器“ cpcm_filter_posts_query”:当menu_item为分类类型并且选中了“创建包含该类别文章链接的子菜单”时,将调用此过滤器。

              Here, you can add or modify the posts query to your liking.

            • 在这里,您可以根据自己的喜好添加或修改帖子查询。

            To add your own wildcards, add the following:

            要添加自己的通配符,请添加以下内容:

              • Filter “cpcm_replace_user_wildcards”: Called after all default CPCM wildcards have been processed.
              • 过滤器“ cpcm_replace_user_wildcards”:在处理完所有默认CPCM通配符之后调用。

              You can see an example in the sample-cpcm-extension directory, included in the plugin code.

              您可以在包含在插件代码中的sample-cpcm-extension目录中看到一个示例。

安装步骤

    1. Upload category-posts-in-custom-menu.php to the /wp-content/plugins/ directory
    2. category-posts-in-custom-menu.php 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

下载地址
https://downloads.wordpress.org/plugin/category-posts-in-custom-menu.1.2.4.zip
-EOF-

AI助手支持GPT4.0