Adding link for logged in user? [closed]

<?php if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); echo ‘<a class=”btn” href=”https://wordpress.stackexchange.com/author/” . $current_user->display_name . ‘”>Channel</a>’; } else { echo ‘Welcome, visitor!’; } ?> Note that get_currentuserinfo() is deprecated in favour of wp_get_current_user().

Singleton plugin activation; create database

There is an error here. You’ve not declared _register_hooks() method. And I instantiated the class like below- global $p; if(empty($p)){ $p = plugin::getInstance(); $p->activate(); } And it worked. For your case that has not worked cause WordPress uses a variable with name $plugin in its life cycle. And your code checks it’s empty or not. … Read more

Call get_template_part() custom permalink

Mapping of URL directly to a template file you describe (mapping URL to a file) is quite rare technique in WordPress, sometimes called static pages. It is rare because in general that’s not how WordPress works. It works by mapping URL to query variables to WP_Query to template hierarchy to template file. Going from URL … Read more

List categories assigned to a post

You can use get_the_category( ) instead. Example: $categories = get_the_category(); foreach( $categories as $category) { $name = $category->name; $category_link = get_category_link( $category->term_id ); echo “<a href=”https://wordpress.stackexchange.com/questions/249463/$category_link”> <span class=” . esc_attr( $name) . “></span> </a>”; }