将分类术语插入不同的表

时间:2014-02-24 作者:user2772219

我在数据库中有不同的表,称为“wp\\U taxterms”。如何在每次创建“客户机”下的新闻分类术语或更新/删除现有术语时插入该表?

编辑:

    if( isset($_GET[\'page\']) && ($_GET[\'page\']=="export-clients") ) {
        global $wpdb;
        $result = $wpdb->get_results("SELECT * FROM wp_special");   
        $categories = get_terms( \'clients\' );

        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: application/octet-stream");
        header("Content-Disposition: attachment; filename=\\"Clients.csv\\";" );
        header("Content-Transfer-Encoding: binary");

        //create a file pointer connected to the output stream
        $output = fopen(\'php://output\', \'w\');

        //output the column headings
        fputcsv($output, array(\'Name\', \'Address\', \'Email\', \'Contact\'));

        foreach($categories as $cat) {
            fputcsv($output, array($cat->name, $cat->description, $cat->email, $cat->contact) );            
        }   

        fclose($output);
        exit;
    }//endif

1 个回复
SO网友:TheDeadMedic

查看法典:http://codex.wordpress.org/Function_Reference/get_terms

例如,如果不重写hide_empty 参数,它将仅检索附加到至少一篇文章的术语。

至于你的代码,没有emailcontact a的属性$term 对象为什么$result = ... 如果你不在任何地方使用它?

结束

相关推荐

Gravity prerender taxonomy

我试图在重力表单中预填充一个类别字段或发布下拉列表。以下是我所拥有的:<?php add_filter(\"gform_pre_render\", \"gform_prepopluate_populate_books\"); //Note: when changing drop down values, we also need to use the gform_admin_pre_render so that the right values are displ