Replies: 2
I just got the pro version of W3TC to be able to use fragment caching. I don’t know if I am missing something. So far:
I have defined in wp-config.php: define( ‘W3TC_DYNAMIC_SECURITY’, ‘1234321’ );
In the options from WP Admin I have set the page cache to Disk: Basic and I have also turned on late initialization under the Page Cache settings section. To be sure that it works, I have tried this and it works as expected (shows current time and doesn’t cache it, it changes when reloading the page):
<!– 1234321 mfunc echo ‘This is my website cached’; –>
echo ‘The time is ‘.date( ‘H:i:s’, time() );
<!–/mfunc 1234321 –>
Now the problem comes. In the top right corner of my webpage, if the user is logged in I show “Hello user” but if the user is not logged in I show “Sign up” and “Log In”. I would like to disable cache from those buttons (or even the whole navbar, I don’t know). This is the code of my navbar:
<nav id="navigation" role="navigation" class="clearfix">
<div class="shadow"></div>
<?php if (class_exists('UserProfile')) : ?>
<?php $up = UserProfile::getInstance(); ?>
<ul id="user-menu" class="menu">
<?php if ($up->current_user->ID == 0) : ?>
<li><a>signup_page) ?>">Sign Up</a></li>
<li><a>profile_page) ?>">Log In</a></li>
<?php else : ?>
<li><a>profile_page) ?>">Hello, <?= $up->current_user_data->first_name ?></a></li>
<?php endif; ?>
<li class="logo_autobild"><a href="http://www.autobild.es/" target="_blank" rel="noopener noreferrer"><img />wp-content/themes/cocheando/img/autobild.png"></a></li>
</ul>
<?php endif; ?>
</nav>
How can I disable cache in this code (as it is HTML + PHP). I am completely lost, I just got the pro version to do this. Thank you in advance
- This topic was modified 4 hours, 44 minutes ago by dacevid.
- This topic was modified 4 hours, 18 minutes ago by Jan Dembowski. Reason: Fixed formatting