<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress Archives - Ashan Jay</title>
	<atom:link href="https://ashanjay.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://ashanjay.com/category/wordpress/</link>
	<description>Developer &#38; Founder of EventON WordPress Event Calendar</description>
	<lastBuildDate>Mon, 03 Aug 2026 23:39:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>
	<item>
		<title>How to Quickly Change Table Prefix for WordPress Database &#8211; Without a Plugin</title>
		<link>https://ashanjay.com/how-to-quickly-change-table-prefix-for-wordpress-database-without-a-plugin/</link>
		
		<dc:creator><![CDATA[AJ P]]></dc:creator>
		<pubDate>Mon, 03 Aug 2026 23:34:20 +0000</pubDate>
				<category><![CDATA[Code share]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://ashanjay.com/?p=1912</guid>

					<description><![CDATA[<p>Skill Level: Moderate to Advance knowledge and usage experience with databases in phpMyAdmin and cPanel. Ever had to change the WordPress database tables prefix to make them more secure? and you had to rely on bulky plugins and other sources? Below I want to share a very easy 3 stage process to change the table [&#8230;]</p>
<p>The post <a href="https://ashanjay.com/how-to-quickly-change-table-prefix-for-wordpress-database-without-a-plugin/">How to Quickly Change Table Prefix for WordPress Database &#8211; Without a Plugin</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Skill Level: Moderate to Advance knowledge and usage experience with databases in phpMyAdmin and cPanel.</p>



<p class="wp-block-paragraph">Ever had to change the WordPress database tables prefix to make them more secure? and you had to rely on bulky plugins and other sources? Below I want to share a very easy 3 stage process to change the table prefix, so it works without breaking anything.</p>



<h2 class="wp-block-heading">Stage 1: Change wp-config.php</h2>



<p class="wp-block-paragraph">Using an FTP client or from cPanel File Manager, open the wp-config.php file &#8212; Search for <strong>$table_prefix = &#8216;wp_&#8217;</strong>.<br>Change this to your custom prefix. Use a less-than-9-character letter-number combo with no meaning, like <strong>&#8220;8J2kIp0_&#8221;</strong>.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="663" height="143" src="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.20.07-PM.png" alt="" class="wp-image-1913" srcset="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.20.07-PM.png 663w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.20.07-PM-300x65.png 300w" sizes="(max-width: 663px) 100vw, 663px" /></figure>



<p class="wp-block-paragraph">Save Changes.</p>



<h2 class="wp-block-heading">Stage 2: Change prefix in phpMyAdmin</h2>



<p class="wp-block-paragraph">Go into your cPanel from your web host &#8212; find phpMyAdmin from Databases section, and open the database view. </p>



<p class="wp-block-paragraph">Click on the correct database table from the left side menu. When you click on the database, it will show all the tables in the database on rigth side of the page. </p>



<p class="wp-block-paragraph">Scroll to the bottom and find <strong>Check all / Check tables having overhead</strong>. </p>



<figure class="wp-block-image size-full"><img decoding="async" width="612" height="231" src="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.26.39-PM.png" alt="" class="wp-image-1914" srcset="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.26.39-PM.png 612w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.26.39-PM-300x113.png 300w" sizes="(max-width: 612px) 100vw, 612px" /></figure>



<p class="wp-block-paragraph">From the drop-down, select Replace table prefix &#8212; in the prompt box, enter the old prefix &#8220;wp_&#8221; changing into new one &#8220;8J2kIp0_&#8221;. Click <strong>Continue</strong>. Now all the table names will be changed. </p>



<h2 class="wp-block-heading">Stage 3: Change related field values in _options and _usermeta</h2>



<p class="wp-block-paragraph">Click on the database table, then the <strong>SQL</strong> tab on the top right side. This will open a Run SQL query box for the database. Copy the SQL code below and change it to your specific prefix names, paste it in the big text box, and click <strong>Go</strong> below the text box.</p>



<pre class="wp-block-code"><code>-- Fix roles
UPDATE `8J2kIp0_options`
SET option_name = REPLACE(option_name, 'wp_', '8J2kIp0_')
WHERE option_name LIKE 'wp_%';

-- Fix user capabilities
UPDATE `8J2kIp0_usermeta`
SET meta_key = REPLACE(meta_key, 'wp_', '8J2kIp0_')
WHERE meta_key LIKE 'wp_%';</code></pre>



<figure class="wp-block-image size-full"><img decoding="async" width="814" height="633" src="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.31.43-PM.png" alt="" class="wp-image-1915" srcset="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.31.43-PM.png 814w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.31.43-PM-300x233.png 300w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.31.43-PM-768x597.png 768w" sizes="(max-width: 814px) 100vw, 814px" /></figure>



<p class="wp-block-paragraph">Running this will show how many rows are affected by this, like below. This part is important for the website users to gain access to the admin side. </p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="817" height="406" src="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.32.37-PM.png" alt="" class="wp-image-1916" srcset="https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.32.37-PM.png 817w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.32.37-PM-300x149.png 300w, https://ashanjay.com/wp-content/uploads/2026/08/Screenshot-2026-08-03-at-4.32.37-PM-768x382.png 768w" sizes="auto, (max-width: 817px) 100vw, 817px" /></figure>



<p class="wp-block-paragraph">That is it. Go back to the website and refresh, clear the browser cache, and see if everything works.</p>
<p>The post <a href="https://ashanjay.com/how-to-quickly-change-table-prefix-for-wordpress-database-without-a-plugin/">How to Quickly Change Table Prefix for WordPress Database &#8211; Without a Plugin</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How I recovered from .htaccess attack on WordPress install</title>
		<link>https://ashanjay.com/htaccess/</link>
		
		<dc:creator><![CDATA[AJ P]]></dc:creator>
		<pubDate>Sat, 08 Jul 2023 03:09:34 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://ashanjay.com/?p=1241</guid>

					<description><![CDATA[<p>.htaccess attacks are very frustrating, period! I wanted to write this to share the numerous methods and techniques I used to recover my websites from a recent .htaccess attack. This type of attack on WordPress install will create .htaccess files on every single directory of the install and that file would have some codes that [&#8230;]</p>
<p>The post <a href="https://ashanjay.com/htaccess/">How I recovered from .htaccess attack on WordPress install</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">.htaccess attacks are very frustrating, period! I wanted to write this to share the numerous methods and techniques I used to recover my websites from a recent .htaccess attack.</p>



<p class="wp-block-paragraph">This type of attack on WordPress install will create .htaccess files on every single directory of the install and that file would have some codes that would modify directory access. I tried various things. I deleted these files, but it got recreated instantly. </p>



<h2 class="wp-block-heading">Change Login Passwords</h2>



<p class="wp-block-paragraph">First step is to change login passwords to something super strong. In wordpress, in Cpanel, and in webhost.</p>



<h2 class="wp-block-heading">Rename The Main Folder</h2>



<p class="wp-block-paragraph">This is the only thing that stopped the auto-generated index.php and .htaccess files from re-creating &#8211; to change the name of the main folder that houses all WordPress install files from FTP. </p>



<p class="wp-block-paragraph">Once you rename this folder, you will have to go into cpanel and make sure the correct folder name is updated for the domain and any other places that use folder location. </p>



<h2 class="wp-block-heading">Security Scan the Hell Out of It</h2>



<p class="wp-block-paragraph">I used <a href="https://wordpress.org/plugins/wordfence/" target="_blank" rel="noreferrer noopener">Wordfence</a> plugin and use their free Scan feature to scan the entire directory of the WordPress install. The beauty of this plugin scanner is, it will show which files are infected or modified, or injected. You can directly delete those files. </p>



<p class="wp-block-paragraph">Alternatively, you can also go into FTP and delete .htaccess files but that is a very tedious process. I found this scanner plugin did a much better job. </p>



<p class="wp-block-paragraph">If core files are modified, you will want to download a new WordPress copy of the same version you have installed and replace those files. Wordfence plugin was able to replace those with core files as well. </p>



<h2 class="wp-block-heading">Add Protections For Future</h2>



<p class="wp-block-paragraph">I have installed Sucuri Security plugin after clearing out everything. I like this plugin because it can send me notifications of any changes to files or changes to content. </p>



<p class="wp-block-paragraph">If your web host provides any security products you can also activate those. </p>



<p class="wp-block-paragraph">You could also add Login Limit Plugins and modify login page url plugins such as <a href="https://wordpress.org/plugins/wps-hide-login/" target="_blank" rel="noreferrer noopener">WPS Hide Login</a>.</p>
<p>The post <a href="https://ashanjay.com/htaccess/">How I recovered from .htaccess attack on WordPress install</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to add an AJAX likes count button in WordPress without a plugin</title>
		<link>https://ashanjay.com/how-to-add-an-ajax-likes-count-button-in-wordpress-without-a-plugin/</link>
					<comments>https://ashanjay.com/how-to-add-an-ajax-likes-count-button-in-wordpress-without-a-plugin/#respond</comments>
		
		<dc:creator><![CDATA[AJ P]]></dc:creator>
		<pubDate>Fri, 23 Apr 2021 17:52:17 +0000</pubDate>
				<category><![CDATA[Code share]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://ashanjay.com/?p=560</guid>

					<description><![CDATA[<p>Adding a likes count with thumbs up icon is quite easy without using a plugin. Below I explain the code I used here in my website. All the code explained goes in the functions.php file in the theme, although it can be modified to use in a plugin as well. Functionality What we are going [&#8230;]</p>
<p>The post <a href="https://ashanjay.com/how-to-add-an-ajax-likes-count-button-in-wordpress-without-a-plugin/">How to add an AJAX likes count button in WordPress without a plugin</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Adding a likes count with thumbs up icon is quite easy without using a plugin. Below I explain the code I used here in my website. All the code explained goes in the functions.php file in the theme, although it can be modified to use in a plugin as well.</p>



<h3 class="wp-block-heading">Functionality</h3>



<p class="wp-block-paragraph">What we are going to do is store likes count in post meta of whichever the post you choose to add a likes count to. The post meta field name will be &#8220;likes&#8221;. Whenever the thumbs-up icon is clicked, the likes count will increment. We are not tracking if a user has already liked an article with this method. However that can be done using cookies. We will use a simple shortcode that can be placed where ever in the site we want to show the likes count button.</p>



<p class="wp-block-paragraph">FYI, the shortcode is using GLOBAL $post variable to get the post ID. And the post ID will be whatever is in the global post value within a wp query loop.</p>



<h2 class="wp-block-heading">Pre-rec Libraries I am using</h2>



<p class="wp-block-paragraph">I am using the free and always awesome <a href="https://fontawesome.com/" target="_blank" rel="noreferrer noopener">fontawesome</a> library to get the thumbs up icon. Aside that, jQuery library which is a standard load on most websites these days. </p>



<h3 class="wp-block-heading">Adding Likes Button Shortcode</h3>



<p class="wp-block-paragraph">This will allow the functionality for shortcode [aj_likes_btn] the context of which you can edit for your liking. This shortcode will print the HTML code where ever the shortcode is placed, to display a thumbs-up icon button and likes count.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="php" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">&lt;?php 
add_shortcode('aj_likes_btn', 'aj_likes_btn');
function aj_likes_btn(){
	global $post;

	$post_id = $post->ID;
	$current_count = get_post_meta( $post_id, 'likes',true);
	$current_count = $current_count ? $current_count : 0;
    
    ob_start();
	?>
	&lt;div class='aj_likes'>
		&lt;p>&lt;a class='aj_thumbsup' href='' data-id='&lt;?php echo $post_id;?>'>
		    &lt;i class="far fa-thumbs-up">&lt;/i>&lt;/a> 
		    Likes (&lt;span>&lt;?php echo $current_count;?>&lt;/span>)&lt;/p>
	&lt;/div>
	&lt;?php
	return ob_get_clean();
}</pre></div>



<h2 class="wp-block-heading">Adding AJAX functionality</h2>



<p class="wp-block-paragraph">This JQuery code can be added to existing javascript file ( in which case the AJAX url must be updated to correct ajax url) or save into a new javascript file called <strong>aj_script.js</strong></p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="php" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">jQuery(document).ready(function($){

$('body').on('click','.aj_thumbsup',function(event){
	event.preventDefault(); // stop click from refreshing page
    
    var OBJ = $(this);
    
    if(OBJ.hasClass('recorded')) return; // stop multiple submissions
    
	var id = $(this).data('id'); // get post ID
	var data_arg = {};
	data_arg['id'] = id;
	data_arg['action'] = 'aj_like_post'; // ajax hook name

	$.ajax({
		beforeSend: function(){},
		type: 'POST',
		url:the_ajax_script.ajaxurl, // Must be updated if adding this to existing
		data: data_arg,dataType:'json',
		success:function(data){
			OBJ.siblings('span').html( data.new_count); // populate with new new_count
			OBJ.addClass('recorded') // mark as thumbsup recorded
			OBJ.find('i').removeClass('far').addClass('fas'); // make thumbs up icon solid
		}
	});
});
});</pre></div>



<p class="wp-block-paragraph">To enqueue the above script use this PHP code, which goes into function.php. Make sure to replace THEME_DIR with correct location if you are saving the javascript code to a different location.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="php" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">&lt;?php
define("THEME_DIR", get_template_directory_uri());
wp_enqueue_script( 'aj_script', THEME_DIR . '/aj_script.js', array( 'jquery' ), 1.0, true );
wp_localize_script( 
	'aj_script', // the handle name of the script
	'the_ajax_script', 
	apply_filters('aj_script_data', array( 
		'ajaxurl' => admin_url( 'admin-ajax.php' ) , 
		'postnonce' => wp_create_nonce( 'aj_nonce' )
	))
);</pre></div>



<p class="wp-block-paragraph">PHP code to process the AJAX request which would record the new incremented like count for the post.</p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="php" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">&lt;?php
add_action( 'wp_ajax_aj_like_post', 'aj_record_like_post' );
add_action( 'wp_ajax_nopriv_aj_like_post', 'aj_record_like_post' ); 
// nopriv allows for nonloggedin users to like as well

public function aj_record_like_post(){

	$post_id = sanitize_text_field( $_POST['id']);

	$current_count = get_post_meta( $post_id, 'likes',true);
	$current_count = $current_count ? $current_count : 0;

	$new_count = $current_count + 1; // add one more like

	update_post_meta( $post_id, 'likes', $new_count); // save new count to the post meta

	echo json_encode(array(
		'status'=>'good',
		'new_count'=>$new_count,
	)); exit;
}</pre></div>



<p class="wp-block-paragraph">CSS code to stylize the looks. </p>



<div style="height: 250px; position:relative; margin-bottom: 50px;" class="wp-block-simple-code-block-ace"><pre class="wp-block-simple-code-block-ace" style="position:absolute;top:0;right:0;bottom:0;left:0" data-mode="php" data-theme="monokai" data-fontsize="14" data-lines="Infinity" data-showlines="true" data-copy="false">.aj_likes{text-align:center; padding:30px 0; font-size:18px;}
.aj_likes a:hover i{transform: scale(1.2);}
.aj_likes a.recorded:hover i{transform: scale(1);}</pre></div>



<p class="wp-block-paragraph">Now add the shortcode [aj_likes_btn] where ever you want viewers to like that post, and it will look like this on the post. If you like this code share, be sure to give my like button a smashing as well 🙂</p>
<p>The post <a href="https://ashanjay.com/how-to-add-an-ajax-likes-count-button-in-wordpress-without-a-plugin/">How to add an AJAX likes count button in WordPress without a plugin</a> appeared first on <a href="https://ashanjay.com">Ashan Jay</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://ashanjay.com/how-to-add-an-ajax-likes-count-button-in-wordpress-without-a-plugin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
