如何在不交换wordpress-core的情况下更改wp-include/soronomy.php中的值

时间:2014-04-20 作者:raccol

我遇到的问题是,即使用户登录,私有帖子的标签也不会显示在小部件标签云中。原因似乎是函数中“post\\u status”的值_update_post_term_count 在wp包括/分类中。php。至少当我将此值更改为“private”时,会显示私有标记。

我的问题是:如何在不编辑分类法的情况下更改此值。php,那么核心呢?这是已更改的功能(在

**...**

):

function _update_post_term_count( $terms, $taxonomy ) {
    global $wpdb;

    $object_types = (array) $taxonomy->object_type;

    foreach ( $object_types as &$object_type )
        list( $object_type ) = explode( \':\', $object_type );

    $object_types = array_unique( $object_types );

    if ( false !== ( $check_attachments = array_search( \'attachment\', $object_types ) ) ) {
        unset( $object_types[ $check_attachments ] );
        $check_attachments = true;
    }

    if ( $object_types )
        $object_types = esc_sql( array_filter( $object_types, \'post_type_exists\' ) );

    foreach ( (array) $terms as $term ) {
        $count = 0;

        // Attachments can be \'inherit\' status, we need to base count off the parent\'s status if so
        if ( $check_attachments )
            $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = \'**private**\' OR ( post_status = \'inherit\' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = \'**private**\' ) ) AND post_type = \'attachment\' AND term_taxonomy_id = %d", $term ) );

        if ( $object_types )
            $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = \'**private**\' AND post_type IN (\'" . implode("\', \'", $object_types ) . "\') AND term_taxonomy_id = %d", $term ) );

        do_action( \'edit_term_taxonomy\', $term, $taxonomy );
        $wpdb->update( $wpdb->term_taxonomy, compact( \'count\' ), array( \'term_taxonomy_id\' => $term ) );
        do_action( \'edited_term_taxonomy\', $term, $taxonomy );
    }
}

1 个回复
SO网友:EuWern

没有办法让私人帖子的标签默认显示,至少目前是这样。我希望wp\\u tag\\u cloud能成为答案,但事实并非如此。除了破解核心代码之外,还有一种选择是通过插件创建自己的小部件。但后来我发现了一个插件,它完全符合我的要求。

https://wordpress.org/plugins/ultimate-tag-cloud-widget/screenshots/

希望这有帮助。

结束

相关推荐

Wrap posts p tags in div

我正在尝试设置博客帖子,以便在添加图像时,将其包装在一个div集中以向右浮动,在添加文本时,将其包装在另一个div集中以向左浮动。因此,所有添加到日志中的图像都将始终具有右侧图像和左侧文本。尝试使用jQuery将所有p标记封装在一个div中,如下所示jQuery(\'p\').wrap(\"<div class=\'post-txt\'></div>\");但我无法确定要将其添加到哪个PHP文件,所以似乎什么都没有发生。如果您能帮助我在wordpress或任何其他选项中找到正确的P