customization - Hide or remove custom post status

admin2025-01-07  5

I want to hide or remove a custom post status when it is set to a specific one.

e.g. If I have a post set to status "pendingreviewf" I want to hide the option to change it to the status "shipedf" and "pricenotaxf". I am using the PublishPress plugin to create the custom status.

The code so far:

function adminstage1() {

    if ( ! function_exists( 'PublishPress' ) )
        return;

    if ( ! PublishPress()->custom_status->is_whitelisted_page() )
        return;

    $hide_post_status = array( 'pendingreviewf' );
    if ( ! in_array( get_post_status(), $hide_post_status) ) {

        ?>
        <style>
            #post_status option[value="shipedf"] {
                display: none;
            }
            #post_status option[value="shipedf"] {
                display: none;
            }

        </style>
        <?php
    }
}
add_action( 'admin_head', 'adminstage1' );

I know it's a mess and maybe isn't making any sense, but I include it to show you my coding skills which are below beginners. Any help appreciated.

I want to hide or remove a custom post status when it is set to a specific one.

e.g. If I have a post set to status "pendingreviewf" I want to hide the option to change it to the status "shipedf" and "pricenotaxf". I am using the PublishPress plugin to create the custom status.

The code so far:

function adminstage1() {

    if ( ! function_exists( 'PublishPress' ) )
        return;

    if ( ! PublishPress()->custom_status->is_whitelisted_page() )
        return;

    $hide_post_status = array( 'pendingreviewf' );
    if ( ! in_array( get_post_status(), $hide_post_status) ) {

        ?>
        <style>
            #post_status option[value="shipedf"] {
                display: none;
            }
            #post_status option[value="shipedf"] {
                display: none;
            }

        </style>
        <?php
    }
}
add_action( 'admin_head', 'adminstage1' );

I know it's a mess and maybe isn't making any sense, but I include it to show you my coding skills which are below beginners. Any help appreciated.

Share Improve this question edited Mar 23, 2019 at 21:55 nmr 4,5212 gold badges17 silver badges25 bronze badges asked Mar 23, 2019 at 19:39 George GeorgiouGeorge Georgiou 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I found the solution i was looking for, if anyone in the future has the same question i am posting the answer.

To make a post with lets say "Status1" to show only "Status2" and hides other statuses like "Status3 and Status4" (with css):

 function hidepoststatus() {

$post = 'Status1';
    global $post;

if ( $post->post_status == 'Status1' ) {

       ?>

<style>

#post_status option[value="Status3"] {
display: none;
}

    #post_status option[value="Status4"] {
display: none;
}

</style>

<?php

  }
}
add_action( 'admin_head', 'hidepoststatus' );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736255348a274.html

最新回复(0)