Now show your WordPress category in two lines

in #blog7 years ago

Nowadays, we discuss many things unknown on our blog. So we need a lot more sections on our blogs because of the need. But for a long time, our blog's sidebar gets bigger and the blog interface looks bad. So to get rid of this problem, many of us want to divide our blog section into 2 columns but we can not do it in PHP despite the desire to not be. So by thinking of everyone, I can easily do some coding in PHP, and share it with you today.

The sections of our blog are usually in the sidebar. So I'm publishing coding based on the sidebar.

First open your sidebar file (sidebar.php). Normally the style of sidebar coding is as below ...

  • ...... ..
  • ...... ..

    Here, in the sidebar DIV, there are various information related to each LI, such as sections, posts, comments, tags etc. So since we want to show the sections in 2 columns, we need to write the code in LI. First select the category which will show the section in our blog's sidebar. Then put the code below there. Suppose we first want to show our division. Then

    </ p>

      After the start, enter
    • Categories

      $ categories = get_categories ('order = ASC');
      $ i = 1;
      echo "

      ";

      foreach ($ categories categories as $ category)
      {
      if ($ i == 1)
      {
      echo "

      ";
      }
      else if ($ i == 2)
      {
      echo "

      ";
      $ i = 0;
      }
      $ i ++;
      }

      echo "

      cat_name. "'>" $ category-> cat_name. " cat_name. "'>" $ category-> cat_name. "

      ";

      ?>

      Save the file and save the file. You will see sections on your sidebar in the 2 columns. If you are dividing the widget, skip it from the control panel. Then your sidebar will show a section once, otherwise it will show 2 times.

      If you wish, you can place icons beside your design next to each section. You have to write some CSS for this.

      Sort:  

      This post recieved an upvote from minnowpond. If you would like to recieve upvotes from minnowpond on all your posts, simply FOLLOW @minnowpond

      great post, as usual!