Home > Back-end >  Issue on my Wordpress Site with the footer.php file
Issue on my Wordpress Site with the footer.php file

Time:03-18

I used a debug and I get the following error: PHP Fatal error Uncaught TypeError: ceil(): Argument #1 ($num) must be of type int|float, string given in /var/www/html/wp-content/themes/ark/footer.php:20

The line reads like this:

$linkOffsetSM = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-sm', '') );

The full div:

<div
        
        data-speed="<?php echo absint( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-speed', 1000) ); ?>"

        <?php

            $linkOffsetXS = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset', 0) );
            if ( empty($linkOffsetXS) ){
                $linkOffsetXS = 0;
            }

            $linkOffsetSM = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-sm', '') );
            if ( empty($linkOffsetSM) ){
                $linkOffsetSM = $linkOffsetXS;
            }

            $linkOffsetMD = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-md', '') );
            if ( empty($linkOffsetMD) ){
                $linkOffsetMD = $linkOffsetSM;
            }

            $linkOffsetLG = ceil( ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-lg', '') );
            if ( empty($linkOffsetLG) ){
                $linkOffsetLG = $linkOffsetMD;
            }

        ?>

        data-offset-xs="<?php echo $linkOffsetXS; ?>"
        data-offset-sm="<?php echo $linkOffsetSM; ?>"
        data-offset-md="<?php echo $linkOffsetMD; ?>"
        data-offset-lg="<?php echo $linkOffsetLG; ?>"
    ></div>

I'm a novice at best with this. The footer.php is messing up my margins on my site. When the file is deleted the site displays perfectly but without a footer. Need to correct the issue in the footer and I'm not sure how.

CodePudding user response:

Try this

Declare int to the data before applying ceil:

Example

$number = function_that_gives_me_a_number();
$ceiled = ceil( (int)$number );

In your case:

$linkOffsetXS = ffThemeOptions::getQuery('layout')->getWithoutComparationDefault('smoothscroll-sharplink-offset-sm', '');
$linkOffsetXS = ceil( (int)$linkOffsetSM );

Do this transformation to all the variables ($linkOffsetXS, $linkOffsetSM, $linkOffsetMD,$linkOffsetLG)

  • Related