Okay
  Public Ticket #1455377
Redirecting the home page
Closed

Comments

  •  6
    qfactor started the conversation

    Hi,


    Thanks for this brilliant theme, I've had a lot of fun getting to learn its many features. My problem is a little odd, as you'll see from the link (this is a temporary staging area for a site I'm building), I want the page to start at the bottom, since the concept is of a tree growing upwards.

    I tried redirecting the root url to the root/#start anchor using a redirect plugin, but this of course threw it into a loop and doesn't work.

    How can I get the page to start from this particular frame when users access the home page (basically when they type hideandseek.magic-marinade.com or reach it via Google, it should start at the bottom most frame)?

    Thank you!

    A





  •  2,733
    Andrew replied

    Hi qfactor,

    This is not really possible with the theme features.

    We would recommend you try some custom JS to maybe hide the page on load - maybe with a loading animation - then scroll the page to the bottom under the loading animation - then remove the animation and then show the page from the bottom as you liked.

    Hope you can implement this as an alternative to the lack of a feature in the theme to help with this.

  •  6
    qfactor replied

    Thanks for the response, Andrew.

    I'm trying to circumvent this by using JS. I'm trying to use the following JS script:

    <script type="text/javascript">
    function load()
    {
    window.location.hash="start"; }
    </script>

    Where "start" refers to a #start anchor I've created on the home page. Could you guide me as to how I can add custom javascript to the site from the Child theme?

    I tried adding the following code to the functions.php of the Child Theme, but it showed some weird text on the top of the page while loading and didn't execute the function I'm looking for.

    add_action( 'wp_enqueue_scripts', 'my_custom_script_load' );
    function my_custom_script_load(){
      wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/custom-scripts', array( 'jquery' ) );
    }


    I'd saved the aforementioned JS script in this folder in the Child Theme's directory. My question, to sum up, is this: how do I add custom Javascript to the Child Theme, and have the site execute it on load.

    Thank you.



  •  2,733
    Andrew replied

    Hi there,

    Could you use jquery ready function that is fired when the page loads.
    Then run your code.

    You could log something to the console i.e. console.log("some text"); to make sure the code is ran.

    Also try and register the script and then enqueue it: 
    https://developer.wordpress.org/reference/functions/wp_register_script/ 

    You can see how the theme loads scripts on the nectar_register_js function in salinet \ functions.php file line 27.

    Hope this helps.