You’ve got some serious syntax errors – once you open that <?php
tag, you’re running PHP – no need to execute it again (i.e. inside your variable assignment strings):
if ( is_user_logged_in() ) { // Only show the output below if a user is logged in
$admin_link = esc_url( admin_url() ); // Escaped admin link
$logout_link = esc_url( wp_logout_url() ); // Escaped logout link
if ( current_user_can( 'manage_options' ) ) { // Current user is an admin, show the admin link
echo ' · <a href="' . $admin_link . '">Admin</a> ·';
}
echo ' · <a href="' . $logout_link . '">Log out</a> ·';
}
Related Posts:
- Show content if parent page has children
- Current post’s author name in the author meta tag
- Conditional statement for parent, child and grandchild pages
- Trying to use Ternary operators with WP Conditionals
- When is is_admin() available?
- Check if current page is wp-admin
- Second Navigation inside header
- Using is_page() in functions.php not working at all
- Output 2 items within the Loop
- conditional statement for custom taxonomy
- How to enqueue CSS and JS only on specific template?
- how could I load a different template part by page
- WordPress, AJAX and pre_get_posts using conditional tags
- If tag equals then show else show
- Conditional statement for dates
- How can I display a div ONLY if it is not a certain term page
- Don’t show certain div on front page?
- If ‘editor’ is empty, then
- Add class to DIV depending on page loaded
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- Undefined index for default custom theme option
- Remove conditional tag from header
- Display an image based on field value
- Multidimensional Array
- “if parent category is” conditional?
- Conditional for Post Format
- conditional: if is page, and all subpages
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- page 1 is not paged
- How to add Text before my Custom Term and hide it when empty
- How can i create a function tag in my plugin
- Add code to the header of posts by particular author
- Display specific page if user signed in
- How to get Post sidebar & footer including html like get_the_content() which only gets content section?
- Widget Logic – display on page and all child
- Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one
- Add code only for blog posts
- How to define Og Meta Tags in header using conditions [duplicate]
- If Month=Particular month display content [closed]
- How to echo a different field if another field is empty?
- Adding else if conditional statement to purchased theme
- Conditional in foreach loop is outputting content twice
- Advanced custom fields Repeater conditional statement not working [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Issues trying to add a href statment with PHP into a PHP Echo Statement [closed]
- if is specific custom post in cpt
- advanced custom fields: repeater field within conditional statement [closed]
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Display current category title on category page
- is_page() not working from within a plugin
- How to handle a custom form in wordpress to submit to another page?
- Is it possible to generate a page without create in the admin?
- Admin Media grid view images won’t load
- How to redirect all 404 in a WordPress subdirectory to the index.php of subdirectory?
- WooCommerce Link to Product Category
- Easiest way to show total number of subpages
- When must I use and verify nonce?
- Can’t load WP function into external function
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- Loading header.php on specific page
- Displaying a button on each post
- How can I set a default category for a custom post type in wordpress?
- Slider loading issue
- Sort posts by custom fields value using dropdown menu
- Cause of Blank Lines Being Added to WP FIles?
- add_cap not working
- Weird 404 URL Problem – domain name being placed at end of urls
- Trouble checking if custom woocommerce checkout field is empty or not
- Styling my own password protected page, how to deal with wrong password?
- WordPress Theme Modification Help
- How to list commenters and days since last commented
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Automatically add images to a menu
- Where can I find the inline-css of my theme header?
- Remove empty terms from array, sort alphabetically, update back to repeating field
- Filter by field with array value in ACF on WP REST API
- custom plugin with upload files does not work
- How do I call an external php non WordPress class into functions.php?
- no_rest_route error on custom routes
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Exclude ipads and tablets form wp_is_mobile code
- WordPress How do I pass a variable from one add_action to another?
- Advance custom fields variable with if statement & Function
- Printing OEmbed URL based on Post selected w/o page refresh
- Include search tags and users in my search results system
- Complex PHP for json_encode > how to handle/output right?
- How to use something like meta_query but for fields?
- Show content by using tags
- Return only certain (html)-elements of the_content()
- Showing featured image of page’s child’s children page
- How to call post title and post summary to other part of site?
- how to run a php code in widget?
- WordPress site cant display media when it’s live
- Restricting Post Content Visibility with Custom Code – where to put it?
- Highlight main menu when on specific posts or pages
- wc_add_notice not working on cart page
- How to convert my comment.html to comment.php
- It’s not showing full content for posts pages in wordpress “[…]” while customing some changes in the style.css file [closed]
- How do I convert a custom field to a php date format? [closed]
- Differences and dis/advanages between: Fast-CGI, CGI, Mod-PHP, SuPHP, PHP-FPM