• Is it possible to disable the sticky posts function and/or hide it from appearing on the admin pages? My theme does not support the feature but the volunteer editors keep trying to use it for all their posts.

    This code removes it from the Quick Edit page, but not the main Add New Post page in the right hand column.

    // Hide sticky posts
    add_action( 'admin_print_styles', 'hide_sticky_option' );
    function hide_sticky_option() {
    global $post_type, $pagenow;
    if( 'post.php' != $pagenow && 'post-new.php' != $pagenow && 'edit.php' != $pagenow )
        return;
    ?>
    <style type="text/css">#sticky-span { display:none!important }
    .quick-edit-row .inline-edit-col-right div.inline-edit-col > :last-child > label.alignleft:last-child{ display:none!important; }</style>
    <?php
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • function k_exclude_sticky( $wp_query ) {  
        set_query_var( 'ignore_sticky_posts', 1 );
    }
    add_action( 'pre_get_posts', 'k_exclude_sticky' );

    // add above line of code on your function.php file

    Hi @safety13,

    Try this:

    add_action( 'admin_print_styles', 'hide_sticky_option' );
    function hide_sticky_option() {
    global $post_type, $pagenow;
    if( 'post.php' != $pagenow && 'post-new.php' != $pagenow && 'edit.php' != $pagenow )
        return;
    ?>
    <style type="text/css">
     body.wp-admin.post-type-post .interface-interface-skeleton__sidebar .components-panel__body.edit-post-post-status .edit-post-post-schedule + .components-panel__row {
        display: none;
     }
    .quick-edit-row .inline-edit-col-right div.inline-edit-col > :last-child > label.alignleft:last-child { 
        display: none !important;
     }
    </style>
    <?php
    }

    I hope this helps! Let me know if this works!

    Thread Starter Safety13

    (@safety13)

    Thanks Kamal and Kaavya but neither solution works.

    Which theme are you using? Please try switching to one of the default core themes like Twenty Twenty-One, add the above code and let me know if that works.

    Thread Starter Safety13

    (@safety13)

    Kaavya,

    Using the most recent version of the Vantage theme.

    You are correct… your solution works perfectly with the Twenty Twenty Two theme.

    Thanks!

    Thread Starter Safety13

    (@safety13)

    Is this a viable option to Kaavya’s solution or am I missing something?

    add_action( 'admin_print_styles', 'hide_sticky_option' );
    function hide_sticky_option() {
    global $post_type, $pagenow;
    if( 'post.php' != $pagenow && 'post-new.php' != $pagenow && 'edit.php' != $pagenow )
        return;
    ?>
    <style type="text/css">
     .components-panel .components-panel__body:first-child .components-panel__row:nth-child(5){
       display: none !important; 
     }
    
    .quick-edit-row .inline-edit-col-right div.inline-edit-col > :last-child > label.alignleft:last-child { 
        display: none !important;
     }
    </style>
    <?php
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable sticky posts function’ is closed to new replies.