• Resolved tbmarkus

    (@tbmarkus)


    Hello there,

    I am happy with WP. Everything works fine and great. But: I’ve got many categories and I always have to scroll up and down when I’m writing a new post and select the categories.

    Is there a plugin or can I edit any .css file to adjust the size of the category box on the right side when I’m writing a new post?

    I would be happy if someone could solve this little problem! ??

    Best wishes

Viewing 13 replies - 1 through 13 (of 13 total)
  • function chewx_admin_cat_height() {
    
    ?>
    
    <style>
    .categorydiv div.tabs-panel { max-height: 400px !important; }
    </style>
    
    <?php
    
    }
    
    add_action('admin_init', 'chewx_admin_cat_height');

    Not tested, but something like that in your functions.php

    Thread Starter tbmarkus

    (@tbmarkus)

    Thanks for the fast answer ?? I checked the file and couldn’t find it ??

    You’d need to copy and paste that code into your functions.php file in your theme.

    Thread Starter tbmarkus

    (@tbmarkus)

    Ah, sorry, I’m not that kind of a coding guy ??

    Just pasted it into the functions.php inside my theme folder but now I see only a blank page! ??

    Shouldn’t do that.

    Can you copy and paste your whole functions.php file here – inc the above code placement. Remove anything that maybe sensitive.

    Thread Starter tbmarkus

    (@tbmarkus)

    Here it is ??

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php
    
    //Short titles for preview link
    
    function short_title($after = '', $length) {
        $mytitle = get_the_title();
        if ( strlen($mytitle) > $length ) {
        $mytitle = substr($mytitle,0,$length);
        echo rtrim($mytitle).$after;
        } else {
        echo $mytitle;
        }
    }
    
    //Removing useless CSS that WP pasts right inside BODY tags... (?)
    
    function remove_gallery_css( $css ) {
        return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
    }
    
    add_filter( 'gallery_style', 'remove_gallery_css' );
    
    //Post thumbsnails support
    
    if ( function_exists( 'add_theme_support' ) ) {
        add_theme_support( 'post-thumbnails' );
    }
    
    //Left sidebar
    
    if ( function_exists('register_sidebar') ) {
        register_sidebar(array(
            'name' => 'Left Sidebar',
            'before_widget' => '',
            'after_widget' => '',
            'before_title' => '<h3>',
            'after_title' => '</h3>'));
    }
    
    //Right sidebar
    
    if ( function_exists('register_sidebar') ) {
        register_sidebar(array(
            'name' => 'Right Sidebar',
            'before_widget' => '',
            'after_widget' => '',
            'before_title' => '<h3>',
            'after_title' => '</h3>'));
    }
    
    //Main menu
    
    add_action( 'init', 'register_my_menus' );
    
    function register_my_menus() {
        register_nav_menus(
            array( 'header-menu' => __( 'Header Menu' ))
      );
    }
    
    //Thanks to https://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ for pagination function
    
    function pagination($pages = '', $range = 9)
    {
         $showitems = ($range * 2)+1;
    
         global $paged;
         if(empty($paged)) $paged = 1;
    
         if($pages == '')
         {
             global $wp_query;
             $pages = $wp_query->max_num_pages;
             if(!$pages)
             {
                 $pages = 1;
             }
         }
    
         if(1 != $pages)
         {
             echo "<span>Page ".$paged." of ".$pages."</span>";
             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>? First</a>";
             if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>? Previous</a>";
    
             for ($i=1; $i <= $pages; $i++)
             {
                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                 {
                     echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."'>".$i."</a>";
                 }
             }
    
             if ($paged < $pages && $showitems < $pages) echo "<a>Next ?</a>";
             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last ?</a>";
    
         }
    }
    
    //Cumstom comments template
    
    function custom_comments($comment, $args, $depth) {
    
        $GLOBALS['comment'] = $comment; ?>
    
        <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
    
            <?php echo get_avatar( $comment, 64 ); ?>
    
            <span class="comment-author"><?php comment_author_link() ?> says:
    
            <?php if ($comment->comment_approved == '0') : ?>
    
            <em>(!) your comment is awaiting moderation</em>
    
            <?php endif; ?>
    
            </span>
    
            <small class="comment-data"><a>" title="Permanent link to this comment"><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a><?php edit_comment_link('Edit', ' | ', ''); ?></small>
    
            <?php comment_text() ?>
    
            <div class="clear"></div>
    
        <?php
    
        }
    ?>
    
    function chewx_admin_cat_height() {
    
    ?>
    
    <style>
    .categorydiv div.tabs-panel { max-height: 400px !important; }
    </style>
    
    <?php
    
    }
    
    add_action('admin_init', 'chewx_admin_cat_height');

    Ah, I tend to omit closing PHP tags, so that’s the error your getting.

    Try:

    <?php
    
    //Short titles for preview link
    
    function short_title($after = '', $length) {
    $mytitle = get_the_title();
    if ( strlen($mytitle) > $length ) {
    $mytitle = substr($mytitle,0,$length);
    echo rtrim($mytitle).$after;
    } else {
    echo $mytitle;
    }
    }
    
    //Removing useless CSS that WP pasts right inside BODY tags... (?)
    
    function remove_gallery_css( $css ) {
    return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
    }
    
    add_filter( 'gallery_style', 'remove_gallery_css' );
    
    //Post thumbsnails support
    
    if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    }
    
    //Left sidebar
    
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'name' => 'Left Sidebar',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>'));
    }
    
    //Right sidebar
    
    if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
    'name' => 'Right Sidebar',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>'));
    }
    
    //Main menu
    
    add_action( 'init', 'register_my_menus' );
    
    function register_my_menus() {
    register_nav_menus(
    array( 'header-menu' => __( 'Header Menu' ))
    );
    }
    
    //Thanks to https://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ for pagination function
    
    function pagination($pages = '', $range = 9)
    {
    $showitems = ($range * 2)+1;
    
    global $paged;
    if(empty($paged)) $paged = 1;
    
    if($pages == '')
    {
    global $wp_query;
    $pages = $wp_query->max_num_pages;
    if(!$pages)
    {
    $pages = 1;
    }
    }
    
    if(1 != $pages)
    {
    echo "<span>Page ".$paged." of ".$pages."</span>";
    if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "? First";
    if($paged > 1 && $showitems < $pages) echo "? Previous";
    
    for ($i=1; $i <= $pages; $i++)
    {
    if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
    {
    echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"".$i."";
    }
    }
    
    if ($paged < $pages && $showitems < $pages) echo "Next ?";
    if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "Last ?";
    
    }
    }
    
    //Cumstom comments template
    
    function custom_comments($comment, $args, $depth) {
    
    $GLOBALS['comment'] = $comment; ?>
    
    <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
    
    <?php echo get_avatar( $comment, 64 ); ?>
    
    <span class="comment-author"><?php comment_author_link() ?> says:
    
    <?php if ($comment->comment_approved == '0') : ?>
    
    (!) your comment is awaiting moderation
    
    <?php endif; ?>
    
    </span>
    
    <small class="comment-data">" title="Permanent link to this comment"><?php comment_date('F jS, Y') ?> at <?php comment_time() ?><?php edit_comment_link('Edit', ' | ', ''); ?></small>
    
    <?php comment_text() ?>
    
    <div class="clear"></div>
    
    <?php
    
    }
    
    function chewx_admin_cat_height() {
    
    ?>
    
    <style>
    .categorydiv div.tabs-panel { max-height: 400px !important; }
    </style>
    
    <?php
    
    }
    
    add_action('admin_init', 'chewx_admin_cat_height');
    Thread Starter tbmarkus

    (@tbmarkus)

    Still a blank page! ??

    I’ve tested my end and works fine.

    Try moving the function to the top.

    <?php
    
    // Enlarge category box
    function chewx_admin_cat_height() {
    
    ?>
    
    <style>
    .categorydiv div.tabs-panel { max-height: 400px !important; }
    </style>
    
    <?php
    
    }
    
    add_action('admin_init', 'chewx_admin_cat_height');
    
    //Short titles for preview link
    
    function short_title($after = '', $length) {
    $mytitle = get_the_title();
    if ( strlen($mytitle) > $length ) {
    $mytitle = substr($mytitle,0,$length);
    echo rtrim($mytitle).$after;
    } else {
    echo $mytitle;
    }
    }
    Thread Starter tbmarkus

    (@tbmarkus)

    Ah – NOW it works! ?? Thank you very much! ??

    Thread Starter tbmarkus

    (@tbmarkus)

    Well – It works, but: When I posted an entry a blank page is shown instead of the “posting added” page (the post is online, but it shows a blank page after I submit the posting.

    The same problem is there when I edit a post. It is edited, but after I click on “submit” a white page shows up.

    Another problem: Featured thumbnail upload doesnt work with the code :/

    Isn’t there a chance to adjust the category box in the wp admin / add entry window without “destroying” other parts? Should be a css thing or something like that

    Thread Starter tbmarkus

    (@tbmarkus)

    Okay – I solved this problem by myself. I searched for “categorydiv div.tabs-panel” inside the .css structure and changed max 200 to 500. It works all written bugs aren’t there! ??

    There must be something conflicting with that function. The whole point of doing it in a function in the theme is so that you can update WordPress and the code will still work, but to answer your question, there most certainly is a way without ‘destroying’ other parts.

    To debug, turn on debugging mode and debug log and check that when you get an error/black page.

    The way you have done it is to edit the core, so when WordPress updates then it will more than likely get overwritten, this is bad practice.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘A bigger category box in WP Admin?’ is closed to new replies.