I don’t know if it’s any more elegant, but if you don’t like duplicating the HTML code, you could do this:
function prefix_poweredby() {
$html="<a href="https://example.com"";
if ( ! is_front_page() ) {
$html .= ' rel="nofollow"';
}
$html .= ' target="_blank">link</a>';
echo $html;
}
add_action('wp_footer', 'prefix_poweredby');
Related Posts:
- How do you completely remove the default header and footer using functions.php?
- Add external js file to footer with id
- Move jQuery and Migrate to footer?
- how to add an image to the footer?
- How can I change the do_action function in footer (copyright area)
- Activate small php condition at footer over page template
- wp_register_script(… $in_footer = true) not working
- How to load jQuery in the footer – nothing works for me
- Which function required?
- Check from functions.php if function exists in footer.php
- wp_footer hook causing text to show on bottom of page
- Moving CDN jQuery to footer does not work?
- shortcode inside post called by ID does not render as expected
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- Link to user’s profile settings page?
- Functions.php code that only runs on localhost?
- hook a functions to change wp-config from functions.php
- Shared functions.php across multiple WordPress websites
- How to restrict actions and filters “properly” by conditions
- Extending auth_cookie_expiration based on user role
- Check if the user has explicitly set an excerpt
- AJAX handler throws 400 (Bad request) – why?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Add inline css to theme
- Shortcode with custom content attribute?
- Add a Post Thumbnail to an RSS Feed with custom size
- Automatically add author’s name to post_tag
- Print Dashboard menu name and link
- Enqueue styles after a plugin
- Develop function get_template_part in functions.php
- Change comment_reply_link URL
- Ajaxing function in widget class
- Super simple shortcode not working
- Using “Read More” link with custom excerpt
- what function can I use to automatically output og tags per page/post?
- Add error message on password protected page ONLY when password introduced was incorrect
- Select pages by category
- Restore Image Title Text
- Output and filter data from a XML url
- Where to start learning more about wordpress templates [closed]
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- How do I create a function that simulate the click on Update button for all posts?
- Reuse variable in hook callback
- Multisite Ajax serialize return error [object Object]
- PHP mixed with some JS code to update WordPress theme settings
- What does this code do? (Injected code hacked)
- Wp admin – Set default value to 999 in comments
- WordPress listen to $_POST in functions.php
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- Can’t properly set the_title add_filter to show short_URL
- WordPress function, Run using Crontab
- Dequeue Script Using Functions.php
- Infinite counting in WordPress
- Tags break custom Excerpt function
- Using $WPDB to create simple array to check against user entered value
- Create custom function for hero image
- Can set_post_thumbnail be used to remove a thumbnail?
- Init action and refresh page after form action
- Replace plugin function with a custom function?
- Delay a function, any function!
- Combine two active_callbacks into one on theme customizer
- How to create shortcode with html and php content?
- Fill empty custom field with other custom field
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- How do I find the code executed when wp_head() is called?
- Problems with functions.php! Error! [closed]
- Output comment_author in array
- Include widget file in functions.php of child theme
- Need help making a short code work
- Is there a function for setting a password to a post?
- WordPress functions.php conditional include another functions file
- reWrite wp-content url to point on my cdn
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- sort title descending with title with number
- Add #primary at the end of navlink permalinks on single posts
- Author social media aren’t shown on the page
- Is there anyway to force is_singular() to be true when not loading template?
- Postback redirect through add_action is not triggered
- How to add class dynamically from templates
- How to change form action of wp-login page with a function
- How to make an If Else on Excerpt Filter
- Translation Function missing text-domain [closed]
- get_comments not working properly after WordPress v4.4 update
- Retrieve a custom form field modified by a filter
- Custom taxonomy not refreshing page on add
- Pagination in Search result
- Custom field not updating via functions upon publishing
- disable WP_error: authentication_failed
- Create input select image URL?
- Including one page with WordPress functions into another
- Dynamically Generating User Meta Field
- Unhook the comment form in Buddypress
- Changing functions.php and .htaccess files
- Code in functions.php appearing on front-end and dashboard [closed]
- Sessions in word press [duplicate]
- “woocommerce_output_related_products” not working
- comment_post function with js not running
- Problem with removing characters “<” – WpAllImport