$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>functions - WordPress menu link doesn't work properly|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - WordPress menu link doesn't work properly

matteradmin9PV0评论

I am developing custom site. The header links work on home-page but when I go inside shop then the home-link becomes siteurl/shop how to solve this?

<div id="content" class="site-content">
  <nav class="navbar navbar-expand-sm navbar-light bg-light">
    <a class="navbar-brand" href="<?php site_url('home'); ?>">Home</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item active">
            <a class="nav-link" href="<?php echo site_url('/shop') ?>">Shop</a>
          </li>

I am developing custom site. The header links work on home-page but when I go inside shop then the home-link becomes siteurl/shop how to solve this?

<div id="content" class="site-content">
  <nav class="navbar navbar-expand-sm navbar-light bg-light">
    <a class="navbar-brand" href="<?php site_url('home'); ?>">Home</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item active">
            <a class="nav-link" href="<?php echo site_url('/shop') ?>">Shop</a>
          </li>
Share Improve this question edited Jan 16, 2019 at 8:06 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Jan 16, 2019 at 5:33 xreonnxreonn 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

I guess you mean this link?

<a class="navbar-brand" href="<?php site_url('home'); ?>">Homee</a>

Then I'm sure it won't work on any other page than home. It's because site_url() function doesn't print anything - it returns its value.

And don't print it either. That means, that the link above is empty ;)

You should change it to this:

<a class="navbar-brand" href="<?php echo site_url('home'); ?>">Homee</a>

PS. Another thing really concerns me in your code. site_url('home') - it should be site_url('/home') (if your home URL is example/home) and site_url('/') (if your home URL is example/).

Post a comment

comment list (0)

  1. No comments so far