Tag: WordPress

  • How To Change Width of Post Content Area In TWENTY TWENTY-ONE WordPress Theme

    How To Change Width of Post Content Area In TWENTY TWENTY-ONE WordPress Theme

    By default the post/page/category/archive content area’s width is less than header/footer/nav/post or page title’s width in the desktop view or large screen size. It’s fucking annoying, not sure why they would do that. Ideally the post etc content area should have same width as title, nav, header footer etc.

    WordPress TwentyTwenty-One Theme Change Post Content Area
    WordPress TwentyTwenty-One Theme Change Post Content Area

    There is very simple way to change it. Just copy following code in your theme’s css or custom CSS in the theme customisation and it will be fixed in no time

    /* Change the content width to be same as header/nav/footer's width */
    @media only screen and (min-width: 822px) {
    	:root {
    		--responsive--aligndefault-width: min(calc(100vw - 8 * var(--global--spacing-horizontal)), 1240px);
    	}
    }

  • How To Redirect www and http to https

    How To Redirect www and http to https

    First Rant..

    Since the men in tower dictated that SSL will become norm for websites we common men are forced to follow their dogma and do as they dictate us to do.

    Not too far in the future, non ssl domains may be blocked by the men in tower all together. So it’s better you start having SSL on your website and redirect http and www to https.

    Redirect http & www to https on Linux and Apache

    Copy following code towards the top of .htaccess file in your web root and all job will be taken care of.

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

    Why to redirect www to https?

    It’s simply because you don’t want users to type r extra letters to reach your website. https://yourdomain.com is the best url you can have unless you have subdomains in which case www may become a necessity.

    Test

    Type http://yourdomain.com and http://www.yourdomain.com in browser one by one and it should redirect to https://yourdomain.com.

    Don’t forget to replace yourdomain.com with your actual domain 😉

    How to add redirect on a self hosted WordPress blog?

    Firstly you should fix the url of your blog. From WordPress Dashboard go to Settings -> General

    Enter your url with https:// in it. This will be your target and default URL.

    WordPress Address (URL)

    Next is to redirect www and http to https. If this is a brand new WordPress installation then you can simply copy and paste above code in .htaccess towards the top.

    Here is what a typical .htaccess file will look like after adding redirect code in it. I’ve highlighted redirect code in bold.

    Don’t forget to test your blog urls after updating .htaccess code.

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    #### Redirect www, http to https ##########
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} ^www. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
    ######################
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php74” package as the default “PHP” programming language.
    <IfModule mime_module>
      AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
    </IfModule>
    # php -- END cPanel-generated handler, do not edit

    If your WordPress blog is not fresh then there are chances that some of the plugins may have been already taking care of the redirect. To check it type http, www urls and if it is already redirecting to https then it’s all good. If not then you can copy and paste code as described above.

  • What Is The Best CMS?

    What Is The Best CMS?

    A Brief Introduction

    For those who are new to CMS, it stands for Content Management System which you use to build a website and publish your content. Your content can be as simple as blog post or a more complex full fledge web app. For any website or web app which requires you to add/edit content/product or articles you need to have a CMS.

    What is the best CMS?
    What is the best CMS?

    Which is the best CMS?

    It’s an enigma and a total mess to ask this question – What is the best CMS – which has been asked millions times by millions of developers and others and which never has a single straight forward answer no matter how many times you ask.

    Sorry to disappoint you, and save your time, that there is no such thing as best CMS. There is no single CMS which can satisfy all your requirements. To save your time further I want to say that don’t delve further into this subject as you will never find an answer.

    In my over two decades of experience in messing with various CMS, I haven’t been zeroed on any single CMS which can take care of any project’s requirements.

    So what CMS to use for my project?

    This is a right question and you will certainly get answer for that provided you have figured out your requirements. I’m also going to list the requirements and the best CMS to use for the same.

    Towards the end of this post I’ve listed the most popular CMSs and their intended usage.

    Best CMS for a Blog

    WordPress and full stop. Don’t look for anything else.

    You can use WordPress do do more than just a blog but it will all end up in a total fucking mess so don’t do that. I’ve seen people using WordPress for a full fledge eCommerce shop and even a web app it’s just totally wrong, and it will end up in a big failure in the end.

    WordPress is a 100% insecure script which can be hacked easily. My guess is that over 90% of all self hosted WordPress sites are hacked or have a backdoor entry where hackers exploit various loopholes to do whatever they want.

    Best CMS for eCommerce Shop

    The first ever full fledge eCommerce CMS which I used was osCommerce. I’ve used it successfully in the past for many online shops. The good news is that it is still around and doing, let’s say, quite ok however world has moved on and we have far better eCommerce solution than osCommerce. I haven’t touched osCommerce in past decade. I wouldn’t recommend using osCommerce any more.

    If I’ve to build a full fledge eCommerce solution then I prefer to use a php framework and I recommend you doing the same. Take any php framework which you are familiar with and customize that to suit your requirements. You may also use Node.js based solution which is gaining popularity now a days.

    Best CMS for Backend For Mobile Apps

    I use yii framework as backend for all mobile apps as it’s flexible and it offers integrated solution for Web App, APIs, Backend for Mobile Apps, Content for front End and everything else you intend to do.

    Now a days Node.js and associated front end solution are also being used but Ive never managed to build a complete system using just Node.JS and front end scripts as it’s fucking mess to get it going.

    List of Top and Most Popular Framework and Usage

    Framework/System/ScriptUsage
    yii framework

    It is PHP based framework and
    my no. 1 choice for everything.
    Web App
    eComemrce Shop
    Backend for Mobile Apps
    Blog
    Forum
    Company Website
    Symfony, Zend and other PHP based frameworkThese are very hard to work with and can be frustrating in the long term, better avoid them.
    WordPressUse only for blog and nothing else. Don’t use wordpress.com though.
    DrupalDon’t use, it’s insecure system
    JoomlaDon’t use, it’s insecure system
    Node.js & related front end solutionsCan be used for anything you require.
    phpBB
    PHP based free open source forum script
    Don’t use, it’s insecure system.
    Django
    Python based framework
    Never got it working, can be good if you can make it work. Can be used for any requirement.

  • How To Install WordPress With One Line Of Code

    How To Install WordPress With One Line Of Code

    Install WordPress With Just One Command
    Install WordPress With Just One Command

    There are two ways to install WordPress. First is to download zip file, upload on your web host and unzip files. It’s messy and unproductive.

    The second method and most productive way to install WordPress is via command line. Most of people again use few commands to install WordPress.

    Here is what genius techies like us do, run one line of command and install WordPress.

    Login to your web host and go to the root folder of domain where you want to install WordPress.

    Copy and paste following command line and viola, your WordPress is installed.

    wget http://wordpress.org/latest.tar.gz; tar xfz latest.tar.gz; mv wordpress/* ./; rm -rf ./wordpress/; rm -f latest.tar.gz

    Add Alias to the above command

    If you have a web host such as a dedicated host and wish to install many WordPress sites then you can add above command line as alias in your bash profile.

    vi ~/.bashrc

    Copy and paste following line

    alias installwp='wget http://wordpress.org/latest.tar.gz; tar xfz latest.tar.gz; mv wordpress/* ./; rm -rf ./wordpress/; rm -f latest.tar.gz'

    Save file and run following command

    source ./.bashrc

    Next time you want to install a WordPress on a domain then go to the home directory (www) of that domain and run following command

    installwp