• The header, footer, theme options went missing on the website.

    I am using the latest Bitnami WordPress Stack on Amazon Lightsail, Approach A: Bitnami installations using system packages.

    When I migrated my website to this new server, the header, footer, theme options went missing on the website.

    Adding the below code in wp-config.php solves the issue.

    I am not sure if this is the right thing do? or does it affect anything.

    If anyone has more knowledge about this, please let me know. Any kind of input will help.

    <?php
    
    if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/wordpress/');
    
    define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
    define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
    define('WP_CONTENT_URL', WP_HOME . 'wp-content');
    define('WP_CONTENT_DIR', realpath(ABSPATH . 'wp-content/'));
    • This topic was modified 3 years, 3 months ago by t-p. Reason: Moved to Fixing WordPress from Everything else WordPress
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there, I’m sure that “the header, footer, theme options” of an old site being migrated are to do with website Theme and not WordPress core. That means, any customization on the old sites Theme will not migrate unless we do it manually.

    Usually most WordPress themes have export options through

    WordPress Dashboard > YourThemeSettingsMenu > Export

    Then we would Import all customization options on to the new site. So if you have a backup of Exported Theme Options, you can import that on the new site. Furthermore:

    in your define rules, you are using http protocol

    should it not be:

    https

    • This reply was modified 3 years, 3 months ago by Tolga.
    Thread Starter kpatelneha23

    (@kaptelneha23)

    Hello @cybepe,

    This new server which is using the latest Bitnami WordPress stack on AWS is for a test. Before we actually decide to move the live site to the new server.
    The test server does not have a ssl certificate and hence the http instead of https.

    I can export theme settings from my local and live, not a problem.

    But the weird situation that happens on this new server is that the the header, footer, theme options go missing and they only show up with I add the absolute path to the wp-content as displayed above in the wp-config.php file.

    I would like to know from other people’s experience if this is a permissions thing or is it a good practice to define absolute path to the wp-content in the wp-config.php file or will it give me any issues in future.

    Thank you,
    Neha

    I understand now, and your assumption is on the right track. Some servers for security reasons use (or not) different options for URL paths.

    Here was my solution in my case I had to create a path using PHP. Now I could access the path like so through functions.php
    //More insights about accessing $_SERVER https://www.php.net/manual/en/reserved.variables.server.php

    //In my case, Dreamhost didn’t allow direct include() or include_once for security reasons so I created a var
    $doc_root = $_SERVER[‘DOCUMENT_ROOT’];

    require_once(“$doc_root/wp-content/themes/jupiter-child/inc/rankya-walker-class.php”);
    require_once(“$doc_root/wp-content/themes/jupiter-child/framework/helpers/global.php”);

    //also in wp-config.php DreamHost adds the below code automatically upon auto install of WP.

    if (preg_match(“/^(.*)\.dream\.website$/”, $_SERVER[‘HTTP_HOST’])) {
    $proto = (!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] !== ‘off’) ? “https” : “http”;
    define(‘WP_SITEURL’, $proto . ‘://’ . $_SERVER[‘HTTP_HOST’]);
    define(‘WP_HOME’, $proto . ‘://’ . $_SERVER[‘HTTP_HOST’]);
    }

    //as you can see, they are automatically searching for their subdomain using $_SERVER[‘HTTP_HOST’]) and putting the domain in a var $proto and then defining WP_SITEURL and WP_HOME. Although this example is for working out http or https, at least it gives you an idea as to how certain servers work around paths

    I would read the help section for your new web server or even raise a support ticket if other members do not reply to this. I hope this helps

    • This reply was modified 3 years, 3 months ago by Tolga.
    • This reply was modified 3 years, 3 months ago by Tolga.
    Thread Starter kpatelneha23

    (@kaptelneha23)

    Hello @cybepe,

    This is all very useful information.

    Thank you, I will try to understand this in-dept and create a ticket in Bitnami WordPress community.

    Thanks again.
    Neha

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Header, Footer, Theme options missing from WordPress website’ is closed to new replies.