How to return wp_login_form(), not echoing

If you’re using wp_login_form() inside a custom function and you don’t want wp_login_form() to echo, which is by default, you shoud set the echo to false as following:

function custom_login(){
  $acc_menu =  wp_login_form(
    array(
       'echo' => false,
    )
  );
 return $acc_menu;
}

Where Do I Put This Code?

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Add register/forgot password links to wp_login_form()

If you want to build a custom login page by using the builtin WP function wp_login_form(), you will notice that there is no register or forgot password link.

If you want to take them back, just hook these links as following:

add_action( 'login_form_bottom', 'add_register_lost_password_link' );
function add_register_lost_password_link() {
$add_links = '<a href="/wp-login.php?action=register">Register</a><a href="/wp-login.php?action=lostpassword">Lost your password?</a>'; 
  return $add_links;
}

There are 3 hooks available:

  • login_form_top
  • login_form_middle
  • login_form_bottom

Where Do I Put This Code?

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Get the most recent tags in WordPress (Shortcode)

Update: Better one here https://voila-blog.com/mysql-get-tags-taxonomy-by-recent-posts-in-wordpress-db/ (MySQL)

If you want to display the most recent tags in WordPress, apply this code to the current theme’s functions.php

function most_recent_tags($args){

 $limit = 10; //limit 10 tags by default
//Get limit tags argument from shortcode
 $numargs = func_get_args();
 if (isset($numargs['limit']) && filter_var($numargs['limit'], FILTER_VALIDATE_INT)){
    $limit = $numargs['limit'];
 }

  $args=array(
    'orderby'=>'term_id',
    'order'=>'DESC',
    'hide_empty'=>false,
    'number'     => $limit,   
    );
    $tags = get_tags($args);
    $trend_tags_html = '<div class="post_tags">';
    foreach ( $tags as $tag ) {
    $tag_link = get_tag_link( $tag->term_id );

    $trend_tags_html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
    $trend_tags_html .= "{$tag->name}</a>";
    }
    $trend_tags_html .= '</div>';

    return $trend_tags_html; 
}

add_shortcode('most_recent_tags','most_recent_tags');

In my case, I will get 20 most recent tags by using the shortcode:

[most_recent_tags limit=20]