I have a server side rendered block that lists cards with page thumbnails and the title wrapped in a link.
I want that the link only gets a href when I’m in the frontend so I avoid clicking on the cards by mistake in the backend and getting redirected to the card page.
Here is my code:
$link = is_admin() ? ""
: " href="https://wordpress.stackexchange.com/questions/343583/" . get_permalink($post->ID) . """;
echo <<<CPTItem
<div class="cpt-list-item"><a class="cpt-list-item__link" $link>
CPTItem;
Unfortunately is_admin() is returning false in the backend in the block itself. I really don’t know why, the only thing I can think about is that it’s because the block is server side rendered.
Is there a way around?