Category: wordpress

Adding TOC in WordPress Posts

Adding TOC in WordPress Posts

Installation

Install Easy Table of Contents plugin, and active it and click on settings to setup.

Settings

Following settings to be set.

Setting Value Description
Enable Support Posts
Auto Insert Posts
Show when 4 Less than 4 headers, won't show toc
Initial View False
Float Right
Title Font Size 50%
Font Size 80%
Headings Header 1 disable Don't show Header 1

Hide title in blog body when displayed in blog list in WordPress

Hide title in blog body when displayed in blog list in WordPress

In order to have a complete document in each blog, blog title is saved in blog body as well.

Blog appears in blog list with title in blog body.

screen

Blog appears in blog list without title (hidden) in blog body.

screen

To hide the blog title in blog list, which is in <h1> or # form, using following code.

.wpbstarter-blog-list .entry-content h1 {
  display: none;
}

Another way to hide it, this can have more control.

.wpbstarter-blog-list .entry-content h1 {
  font-size: 0;
  width: 1px;
  height: 1px;
  display: inline-block;
  overflow: hidden;
  position: absolute!important;
  border: 0!important;
  padding: 0!important;
  margin: 0!important;
  clip: rect(1px,1px,1px,1px);
}

Create your website with blocks

Create your website with blocks

This is an example page from WordPress.

Add block patterns

Block patterns are pre-designed groups of blocks. To add one, select the Add Block button [+] in the toolbar at the top of the editor. Switch to the Patterns tab underneath the search bar, and choose a pattern.

Frame your images

Twenty Twenty-One includes stylish borders for your content. With an Image block selected, open the "Styles" panel within the Editor sidebar. Select the "Frame" block style to activate it.

Overlap columns

Twenty Twenty-One also includes an overlap style for column blocks. With a Columns block selected, open the "Styles" panel within the Editor sidebar. Choose the "Overlap" block style to try it out.

“Roses Trémières” by Berthe Morisot
“In the Bois de Boulogne” by Berthe Morisot
“Young Woman in Mauve” by Berthe Morisot

WordPress URLs point actual server behind NGINX

WordPress URLs point actual server behind NGINX

NGINX did not translate URL correctly

When accessing server via NGINX, it didn't translate URLs in page to the URL accessing.

For example, the URL is https://example.com/sample.html, the server behind is https://192.168.1.11/sample.html, the NGINX is still leaving it without translating.

I have done following, but not useful

  1. Updated both options siteurl and home in database
update wp_options set option_value='http://newhost:8080' where option_name='siteurl';
update wp_options set option_value='http://newhost:8080' where option_name='home';
  1. Added host and port in wp_config.php
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
      $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
      $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
}

Someone suggested following lines as well, but I didn't do it.

define('WP_HOME','https://test.com/blog/');
define('WP_SITEURL','https://test.com/blog/');
  1. Updated NGINX configuration.
proxy_pass http://newhost

Solution

Modify NGINX configuration

Configure https

server {
    server_name  blog.bianxi.com;

    # SSL configuration
    listen 443 ssl;

    ssl_certificate     conf.d/www.bianxi.com.crt;
    ssl_certificate_key conf.d/www.bianxi.com.key;

    location / {
        proxy_pass      'http://192.168.1.14:8080';
        proxy_http_version 1.1;
        proxy_buffering off;
        proxy_read_timeout    90;
        proxy_connect_timeout 90;
        proxy_redirect        off;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header Proxy "";
    }
}

Configure http redirect

server {
    listen       80;
    server_name  blog.bianxi.com;

    return 301 https://$host$request_uri;
}

Config wp-config.php

Add following lines in wp-config.php

//$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",  $_SERVER['REQUEST_URI']);

if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;

    define('WP_HOME','https://blog.bianxi.com/');
    define('WP_SITEURL','https://blog.bianxi.com/');
}

If change URL is required

Change location in NGINX configuration file, and the URL replace were used if requires changing of URL as well in wp-config.php file.