标签: WordPress采集

  • WordPress 声音、音频主题 JSounds 在线播放音频

    WordPress 声音、音频主题 JSounds。

    主要功能

    • 自定义标签排序
    • 男女分类中搜索对应分类的音频
    • ABCS类筛选
    • 手机自适应
    • 支持多重标签、自定义文字搜索。

  • WordPress 如何获取文章发表用户ID

    WordPress 如何获取文章发表用户ID

    WordPress插件/主题开发中,如何获取文章发表用户的ID ?

    LOOP循环中

    官方文档:

    get_the_author_meta( string $field = '', int|false $user_id = false )

    Retrieves the requested data of the author of the current post.

    Description 

    Valid values for the $field parameter include:

    • admin_color
    • aim
    • comment_shortcuts
    • description
    • display_name
    • first_name
    • ID
    • jabber
    • last_name
    • nickname
    • plugins_last_view
    • plugins_per_page
    • rich_editing
    • syntax_highlighting
    • user_activation_key
    • user_description
    • user_email
    • user_firstname
    • user_lastname
    • user_level
    • user_login
    • user_nicename
    • user_pass
    • user_registered
    • user_status
    • user_url
    • yim

    Parameters

    $field

    (string) (Optional) The user field to retrieve.

    Default value: ”$user_id

    (int|false) (Optional) User ID.

    Default value: false

    Return

    (string) The author’s field from the current author’s DB object, otherwise an empty string.

    在循环外面通过以下方法获取用户ID

    $author_id = get_post_field ('post_author', get_the_ID() );
  • WordPress 插件开发 自定义文章类型中 add_meta_box  如何使用原生的分类/标签显示并保存数据?

    WordPress 插件开发 自定义文章类型中 add_meta_box 如何使用原生的分类/标签显示并保存数据?

    近日我们在改版 WordPress 采集插件 wp-jpost , 将代码内容进行重构,我们尽量使用 WordPress 原生的代码来做。

    当我们在插件开发中使用 register_post_type 函数来自定义文章类型(wordpress使用register_post_type 函数创建自定义文章类型)时,可能需要 register_taxonomy 来注册一个对应的分类,但是我们这里想使用原生的 分类时,一开始我们使用了 add_meta_boxWordPress函数:add meta box(自定义添加Meta模块))的 post_categories_meta_box 来进行注册。

    但是后台可以正常显示,但是保存数据时并不能将分类数据保存下来,后来我们查阅相关文档之后发现必须使用 register_taxonomy_for_object_type 函数来调用。同样的标签类型也可以使用。

    <?php
    add_action( 'init', 'jiloc_add_page_cats' );
    function jiloc_add_page_cats(){
        $slug = "jiloc";
        register_taxonomy_for_object_type( 'category', $slug );
        register_taxonomy_for_object_type( 'post_tag', $slug );
    }
    

    WordPress函数:register post type (自定义文章类型)用法和范例 , 在这篇文章中我们进行了详细的记载。

WeChat