If there is only one search result, skip the results page and jump directly to the content 🔧
Add the following to your theme functions.php file: Source: WordPress搜索功能结果只有一个时直接跳转到结果文章页面
Add the following to your theme functions.php file: Source: WordPress搜索功能结果只有一个时直接跳转到结果文章页面
Step 1. Add the following inside your theme functions.php file or create a new Child theme first and add the code to it: Step 2. Add the shortcode [total_posts] anywhere on the website where you want to display the total number of posts: And it will display the number. 🙂
WordPress has an HTML meta generation tag that shows that your website is running WordPress and which version exactly. If you right-click on this page and choose View Source, you can find this tag by searching for “generator” in the source code. You should see something similar to: <meta name=”generator” content=”WordPress 6.0.3″ /> This code … Read full article →
To display the number of total views for all posts inside a WordPress category the simplest solution is to count the page views of each post, and then call the post views on the category page. Open the functions.php file of the current template and add the following code: And to display the number of … Read full article →
While developing a custom site I was in a need to represent how many minutes/hours/days the post was published ago instead of the published date. The logic of the code is simple: TIME DISPLAY less than 1 hour XX minutes ago 1 – 24 hours XX hours ago 24 hours – 7 days XX days … Read full article →
The following code snippet will automatically generate Alt Text for all featured images from the Post Title. If you are looking for more settings, check the SEO Friendly Images plugin.
This is another neat feature that I needed but didn’t really want to use another plugin to accomplish it. To display user roles inside WordPress comments like on the image above ? use the following code snippet:
Here is a small snippet that you can add to your functions.php file to show different menus to logged-in users in WordPress. In this example 5 is the menu ID of the menu shown to logged-in users and 6 is the ID for the menu shown to guests. So, create two menus and copy their … Read full article →
I recently encountered this awesome plugin Custom Highlight Color by Nick Halsey that allows you to set custom color for highlighted text on your WordPress website. And the plugin is great, does what it is supposed to, but I just wanted to take it one step further and set random colors. To set a custom … Read full article →
WordPress uses the wp_commentmeta and wp_comments tables to store comments and their data. To delete all comments in WordPress simply empty those tables in the database: To delete all spam comments use: To delete all unapproved comments use: NOTE: In the above commands change wp_ prefix with the table prefix that you are using *(view … Read full article →