Changing WordPress author name in database

Take a back up before trying anything! 🙂 (I use the Duplicator plugin for that, if you don’t already have a solution. When you delete users in WordPress, it gives the option to attribute conent to another user. Would this suit your needs?

Author permalink

What you need to do is make sure you have a unique base for your author permalinks. This sample code would do what you need. You may need to flush the rules after you include this code in your functions.php. A rewrite rules inspector plugin will help you get this all working smoothly: function wpse263881_init() … Read more

Display posts on parent post if author coincides

I found it (easy one): In functions.php: // Allow author for custom post function allowShowAuthor() { add_post_type_support( ‘cust_post-type’, ‘author’ ); } add_action(‘init’,’allowShowAuthor’); In the content template: <ul class=”author-posts”> <?php $current_page_author = get_the_author(); $catquery = new WP_Query( ‘cat=7&posts_per_page=30&order=DESC&author_name=” . $current_page_author ); while($catquery->have_posts()) : $catquery->the_post(); ?> <li class=”author-post”><?php the_content();?></li> <?php endwhile;?>

Numbering author posts in posts query

You could have an authors totals array and on each iteration you would increment that author’s key: <?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <?php $author_count = isset( $authors_totals[ get_the_author_meta(‘ID’) ] ) ? int_val( $authors_totals[ get_the_author_meta(‘ID’) ] ) + 1 : 1; ?> Date: <?php the_date(‘d/m/Y’); ?> Title: <?php the_title(); … Read more

How to avoid one code multiple times instead do that through some function? Shortcode, but I think shortcode is not used in main theme’s core files?

You can use PHP’s includes like this: include dirname(__FILE__).’/components/authorSocials.php’; but you should remember about providing the data to your component. Since the idea is that you will you use it in different places, not always the default values will be available and will be the right ones, so you should add some more code to … Read more

Open the_author_link() in a new window

Yes, you have to get the url by user’s meta: <?php if ( get_the_author_meta(‘url’) ) { // Author has website url $author_url = get_the_author_meta(‘url’); } else { // Author doesn’t have website url, so get Author Posts Page $author_url = get_author_posts_url( get_the_author_meta(‘ID’) ); } ?> <a href=”https://wordpress.stackexchange.com/questions/273597/<?php echo $author_url; ?>” target=”_blank”>Author’s website</a>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)