[SOLVED] Custom slug (url) for my posts aren't working in Simple Blog

Ask for help or provide support to other members.
Post Reply
StarClown
Posts: 8
Joined: Tue Jun 03, 2025 6:01 am

[SOLVED] Custom slug (url) for my posts aren't working in Simple Blog

Post by StarClown »

Hello everyone.

I'm still dealing with the Simple Blog plugin which is what I needed the most to be working well. My website is live already (nobody is visiting yet), is about Recipes, is in Spanish but my admin dashboard still in English since I'm bilingual. Anywho... I would love to have my "posts" url being like this:
"mywebsitename.com/recetas/the-title-of-my-recipe" instead of "mywebsitename.com/post/the-title-of-my-recipe"

So, I've change class.SimpleBlog.php this way:

Code: Select all

global $Wcms;

class SimpleBlog {
	public $slug = 'recetas';

	private $Wcms;

	private $db;

	private $dbPath;

	private $dateFormat = 'd F Y';

	private $path = [''];

	private $active = false;

	public function __construct($load) {
		global $Wcms;
		$this->dbPath = $Wcms->dataPath . '/simpleblog.json';
		if ($load) {
			$this->Wcms =&$Wcms;
		}
	}
Unfortunately it doesn't work because, for some reason, the new posts are not saving correctly. I have checked the simpleblog.json and this what it's showing:

Code: Select all

{
    "title": "Recetas",
    "posts": {
        "hello-world": {
            "title": "Hello, World!",
            "description": "This blog post and the first paragraph is the short snippet.",
            "keywords": "#your, #keywords #here",
            "date": 1752206742,
            "body": "This is the full blog post content. Here's some more example text. Consectetur adipisicing elit. Quidem nesciunt voluptas tempore vero, porro reprehenderit cum provident eum sapiente voluptate veritatis, iure libero, fugiat iste soluta repellendus aliquid impedit alias."
        },
        "rellenos-de-coliflor-con-huevo": {
            "title": "Rellenos de Coliflor con Huevo",
            "description": "This blog post and the first paragraph is the short snippet.",
            "keywords": "#your, #keywords #here",
            "date": 1752206782,
            "body": "This is the full blog post content. Here's some more example text. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem nesciunt voluptas tempore vero, porro reprehenderit cum provident eum sapiente voluptate veritatis, iure libero, fugiat iste soluta repellendus aliquid impedit alias."
        }
    }
}
As you can see, the second POST have my title in Spanish, but all content is not saving at all. I would appreciate some little help on this please.

Thank you guys!
Last edited by StarClown on Sun Jul 13, 2025 7:41 pm, edited 1 time in total.
User avatar
nox
Posts: 84
Joined: Sat May 23, 2020 9:02 pm

Re: Custom slug (url) for my posts aren't working in Simple Blog

Post by nox »

Hey StarClown,

not sure why the last post is removed but it is happening to me too. There are several places where to change default "Blog" entry.

class.SimpleBlog.php (plugins directory)
line 6: https://github.com/robiso/simple-blog/b ... L6C2-L6C24

Code: Select all

public $slug = 'blog';
This is a blog slug, the last part of the url - mywebsite/blog

line 161: https://github.com/robiso/simple-blog/b ... g.php#L161

Code: Select all

<a class="nav-link" href="{$this->Wcms->url($this->slug)}">Blog</a>
Menu entry, for example "My Recipes"

simpleblog.json (data directory):
line 2:

Code: Select all

"title": "Blog"
Shows in the browser tab as page title (on all blog posts page), for example: My Website - Blog

And this one is the issue, changing it will delete recent (latest) posts. But after that, creating a new post again will save it (and future posts) as it should. Changing line 2 again to something else, will delete latest posts from database again. So pick a name for blog and stick with it.

Also, do a class.SimpleBlog.php backup and simpleblog.js (backup weekly, monthly).
StarClown
Posts: 8
Joined: Tue Jun 03, 2025 6:01 am

Re: Custom slug (url) for my posts aren't working in Simple Blog

Post by StarClown »

nox wrote: Sun Jul 13, 2025 6:03 am Hey StarClown,

not sure why the last post is removed but it is happening to me too. There are several places where to change default "Blog" entry.

class.SimpleBlog.php (plugins directory)
line 6: https://github.com/robiso/simple-blog/b ... L6C2-L6C24

Code: Select all

public $slug = 'blog';
This is a blog slug, the last part of the url - mywebsite/blog

line 161: https://github.com/robiso/simple-blog/b ... g.php#L161

Code: Select all

<a class="nav-link" href="{$this->Wcms->url($this->slug)}">Blog</a>
Menu entry, for example "My Recipes"

simpleblog.json (data directory):
line 2:

Code: Select all

"title": "Blog"
Shows in the browser tab as page title (on all blog posts page), for example: My Website - Blog

And this one is the issue, changing it will delete recent (latest) posts. But after that, creating a new post again will save it (and future posts) as it should. Changing line 2 again to something else, will delete latest posts from database again. So pick a name for blog and stick with it.

Also, do a class.SimpleBlog.php backup and simpleblog.js (backup weekly, monthly).
I just can't believe this lol :lol:
I've been messing up with all files where I found "blog" or "posts" and that's why it wasn't working. I modify "new.php", "save.php" and of course all the lines you mentioned.

VERY HONESTLY, YOU ARE THE BEST MY FRIEND. Thank you!!
Post Reply