Home Forums Backend Issues (wp-admin) Customize Admin Post List


Customize Admin Post List

  • I have a custom post type “issue” and relationship with custom post type “article”. What I want is, to create the issue cpt as a taxonomy for the article cpt, and showing it in article post list. When the users add new issue, so the taxonomy will updated it self. And the final result is, I can filtering the articles only based on the issue name.

    I am using this code but not working

    //Articles Filter by Issue
    function restrict_articles_by_issue() {
        global $wpdb;
        $issues = $wpdb->get_col("
            SELECT DISTINCT meta_value
            FROM ". $wpdb->postmeta ."
            WHERE meta_key = 'issue'
            ORDER BY meta_value
        <label for="issue">Issues:</label>
        <select name="issue_restrict_articles" id="issue">
            <option value="">Show all</option>
            <?php foreach ($issues as $issue) { ?>
            <option value="<?php echo esc_attr( $issue ); ?>" <?php if(isset($_GET['issue_restrict_articles']) && !empty($_GET['issue_restrict_articles']) ) selected($_GET['issue_restrict_articles'], $issue); ?>>
              $issue   = get_post($issue);
              echo $issue->post_title;
            <?php } ?>
    function posts_where( $where ) {
        if( is_admin() ) {
            global $wpdb;       
            if ( isset( $_GET['issue_restrict_articles'] ) && !empty( $_GET['issue_restrict_articles'] ) && intval( $_GET['issue_restrict_articles'] ) != 0 ) {
                $issue_number = intval( $_GET['issue_restrict_articles'] );
                $where .= " AND ID IN (SELECT post_id FROM " . $wpdb->postmeta ." 
    WHERE meta_key='issue' AND meta_value=$issue_number )";
        return $where;
    add_filter( 'posts_where' , 'posts_where' );

    Anyone can help?

Viewing 1 post (of 1 total)

The topic ‘Customize Admin Post List’ is closed to new replies.