Add a “Delete Post” Link to your WordPress Posts!

Add a simple delete link right on your website that is running WordPress. Tested with WordPress version 5.1.

Since the PHP code is written by me it looks like crap, but it doesn’t really matter since the admin is the only one who will see it.

Add this code inside the WordPress loop and reload your website.
If you have logged in as Admin you should see a “[Delete Post]” link somewhere.

When you click it a dialog will pop up, asking you to confirm to delete the post.
I didn’t want the page to reload every time I did delete stuff, that’s why the small iframe is added. It will simply load the delete link inside it. (Told you it was crap code, but it works.)

WordPress Code:
<?php if ( is_super_admin() ) { ?>
<p><a onclick="return confirm('Do you want to delete this post?')" href="<?php echo get_delete_post_link( $post->ID ) ?>" target="deleteframe">[Delete Post]</a></p><iframe name="deleteframe" width="200px" height="35px"><a href="https://www.nordicnode.com/">NordicNode</a></iframe>
<?php } ?>

That’s it!

Force HTTPS and/or WWW on your WordPress site!

As you probably know by now. Google is starting to add a new ranking factor to their ever-changing algorithm.

It’s SSL that they want us to use but it’s a good thing since the data you send and receive from a server will be encrypted and a bit harder for people that might try to gather information like credit card numbers, passwords and other sensitive information.

First, make sure you’re happy with your Permalinks settings. Once that is done, open the file named “.htaccess” and after taking a backup of it, change it to the similar bit of “code” below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# Force www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Force SSL
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
</IfModule>
# END WordPress

Just add the “Force www” part for adding www if you want it. The SSL part below is what’s important.

Save the file and try going to some of your old URLs.

Get Latest Post In WordPress (Tiny PHP Code)

Here’s a useful code snippet in PHP for WordPress to get a link to the newest (latest, freshest… you get the idea) post in WordPress.

Code starts here:

$latest = get_posts(array('numberposts' => 1));
$url = get_permalink($latest[0]->ID);
echo "<a href='" . $url . "'>Click here and read our latest post!</a>";

Yeah, that’s it. Have a great day!

VB.net: Get a String between 2 words(any text) inside a larger string – Supereasy!

First off, I didn’t not write this code. I might have modified it but I’m not sure since I’ve had it around for quite some time.
If you’re the creator, thanks! It’s been handy. And comment and I’ll add a “credit-link” in this post. 😉

The code to get the value, text or string or whatever you choose to call it is so easy to use, short and it’s handy in many different kind of applications.
If you’re writing a Scraper in VB.net, this is a perfect Function that surely will be useful for you.

Lets say you have a string with the following content:
"Erik Johan Jonas Johanna Martin David"

And you want to pick out the name between Johanna and David:

Dim FindIt As String = GetBetween(Haystack, "Johanna", "David")
MessageBox.Show(FindIt)

So, I used Dim in the same line to set up a string to store the text we’re picking out and then used the function called GetBetween to extract the text.
There will be spaces that you might want to use Trim on since I didn’t include the space as a prefix and suffix when using the GetBetween function.

The code is in the full post. Follow the link!

Continue reading VB.net: Get a String between 2 words(any text) inside a larger string – Supereasy!