Website Tutorial WordPress displays article page views
When you build your own website using WordPress, if you want to display the page views of each article on the website, you will generally use a WordPress page views plug-in, which can conveniently count the page views of each article on our website. First, add the following code to the wordpress template function functions.php…
Website Tutorial How To Add Pagination To WordPress
Step 1: Put the following code into the template function file functions.php of the WordPress theme you are using. function kriesi_pagination($query_string){ global $posts_per_page, $paged; $my_query = new WP_Query($query_string .”&posts_per_page=-1″); $total_posts = $my_query->post_count; if(empty($paged))$paged = 1; $prev = $paged – 1; $next = $paged + 1; $range = 2; // only edit this if you want…
Website Tutorial WordPress batch change domain name sql operation statement
The general modification method is to click and modify one database table at a time, but this method is too inefficient. If you encounter a large number of never-path addresses in the article, the workload is even greater. At this time, we can implement batch modification by executing the sql statement in phpmyadmin. (If you…
Website Tutorial What to do if the WordPress blog changes the site address (URL) and cannot log in?
When you change the site address of the wordpress program and save the settings, if you find that you wrote the wrong address and want to change it, you will find that you can’t log in at all. You may find the directory and add wp-login.php, open it successfully, but enter the correct username and…
Website Tutorial wordpress set up pseudo-static and 301 redirection
Everyone knows that it is relatively easy to implement pseudo-static and 301 redirection on Linux hosts. If you are using a Linux host, when setting up a fixed connection, the WordPress backend will automatically add the following function to the .htaccess file. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f…
Website Tutorial Add “active” class to wp_nav_menu() current menu item
In functions.php use this: add_filter(‘nav_menu_css_class’ , ‘special_nav_class’ , 10 , 2); function special_nav_class ($classes, $item) { if (in_array(‘current-menu-item’, $classes) ){ $classes[] = ‘active ‘; } return $classes; }
Website Tutorial How to use next_post_link to display the link to the next post from a specific category
Below is a code snippet to display the link to the next post from a specific category using the next_post_link function: <?php next_post_link( ‘%link’, ‘Next post in Category’, true, ”, ‘category_id’ ); ?> This code snippet outputs the link to the next post from a specific category with the link text “Next post in Category”.
Website Tutorial Display Related Posts By Tags in WordPress
<ul id=”tags_related”> <?php global $post; $post_tags = wp_get_post_tags($post->ID); if ($post_tags) { foreach ($post_tags as $tag) { $tag_list[] .= $tag->term_id; } $post_tag = $tag_list[ mt_rand(0, count($tag_list) – 1) ]; $args = array( ‘tag__in’ => array($post_tag), ‘category__not_in’ => array(NULL), ‘post__not_in’ => array($post->ID), ‘showposts’ => 6, ‘caller_get_posts’ => 1 ); query_posts($args); if (have_posts()) { while (have_posts()) { the_post();…
Website Tutorial CodePen Home Remove dots from Ul and li
In some cases, we are required to remove the bullets of unordered and ordered lists. The removal of the list bullets is not a complex task using CSS. It can be easily done by setting the CSS list-style or list-style-type property to none. The list-style-type CSS property is used to set the marker (like a disc, character, or the custom counter style) of…