Getting the author name on author archive page

I don’t know what are you trying to do with if-else statement, but to display author name with their published post link use this code: <span>Article posted by <?php the_author_posts_link(); ?></span> Tweak it according to your need. One more thing: You need to call the_author_posts_link() function within the while loop (Yes, the same while loop, … Read more

Calling directories to load in wordpress

I usually split my theme’s functions into several files as well, and include those in my functions.php, like so: // load helper functions require_once get_stylesheet_directory().’/inc/helper-functions.php’; // load admin functions if (is_admin()) require_once get_stylesheet_directory().’/inc/admin-functions.php’; // load theme functions require_once get_stylesheet_directory().’/inc/theme-functions.php’; // load post functions require_once get_stylesheet_directory().’/inc/post-functions.php’; // load WooCommerce functions if (in_array(‘woocommerce/woocommerce.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))) require_once get_stylesheet_directory().’/inc/woocommerce-functions.php’; … Read more

PHP help get_template_directory + PHP include

get_template_directory() and get_stylesheet_directory() both pull form the wp-content/themes directory. The difference being that the former always pulls from the parent theme directory. Neither take parameters, so you just concatenate the rest of the path to the string returned from the appropriate function. That is: include get_template_directory().’/inc/social.php’; If your file is not in your theme directory, … Read more

Link posts to pages for breadcrumbs

You need to go and have a look at template hierarchy for custom post types. I believe your custom post type is tennis. So you would make a copy of your theme’s archive.php template and call it archive-tennis.php You can now style that template to your liking. Just remember, you don’t need to add or … Read more

I want to select the from values from database in WordPress? [closed]

Read the wpdb docs and don’t forget to protect your query: global $wpdb; $table_name = $wpdb->prefix . “item”; $login_name = sanitize_user( $_POST[‘login_name’] ); //assuming you’re dealing with username $prepare = $wpdb->prepare( “SELECT * FROM $table_name WHERE uname = %s”, $login_name ); $myrows = $wpdb->get_results( $prepare ); //output results echo ‘<pre>’ . print_r( $myrows, true ) … Read more

Performance impact of rewriting WordPress URLs

From performance point of view what takes time is matching URL against generated (and stored persistently so it’s not rebuilt continuously) list of regular expressions. Since URLs are (most of the time) insignificantly short in text volume the amount of those regular expression rules has most impact on performance. Unless you generate unreasonably many rules. … Read more