Rasheed4u Posted January 13, 2023 Share Posted January 13, 2023 I'm modifying a PHP blog for a project and realized that a post URL shows ID instead of title of the post. How can I correct this? Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/ Share on other sites More sharing options...
ginerjm Posted January 13, 2023 Share Posted January 13, 2023 Huh? Are you really asking this question? Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604587 Share on other sites More sharing options...
Rasheed4u Posted January 13, 2023 Author Share Posted January 13, 2023 Yeah I will appreciate if you can assist. Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604591 Share on other sites More sharing options...
ginerjm Posted January 13, 2023 Share Posted January 13, 2023 We would like it if you would assist by giving us some context. Without seeing ANYTHING at all about your code, how the heck are we supposed to help you. Geez! Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604592 Share on other sites More sharing options...
Rasheed4u Posted January 13, 2023 Author Share Posted January 13, 2023 So before going for premium, I tried free hosting to fix issues. The URL link to a Post displays like "http://arewahouse.epizy.com/single.php?id=9&i=1" Instead of http://arewahouse.epizy.com/meet_chinese_lady_who_speaks_hausa Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604595 Share on other sites More sharing options...
ginerjm Posted January 13, 2023 Share Posted January 13, 2023 And who or what is creating that url? That would be nice to know if we are supposed to tell you how to alter it, don't you think? Do we have to pull this info from you or are you going to get to the point and help us to help you? PS - free hosting. You get what you pay for. Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604596 Share on other sites More sharing options...
Solution Rasheed4u Posted January 13, 2023 Author Solution Share Posted January 13, 2023 If you don't know anything kindly shut the fucck off. I explained that the free hosting was to verify issues before finally going live on premium. Stop being unnecessarily rude and condescending to strangers MF. As for the question above, I have gotten a solution. Anyone with similar issue can use this code // get all posts $posts = Post::all(); // loop through all posts foreach ($posts as $post) { // convert the title into a slug and save it to the slug field $post->slug = Str::slug($post->title); // save the post $post->save(); } Quote Link to comment https://forums.phpfreaks.com/topic/315794-how-to-show-post-title-instead-of-singlephpid3-in-url/#findComment-1604597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.