Closed Telstar1980 closed 8 years ago
Do you mean that it should auto update based on the title? Yes, I still need to add that part. Needs to be done before 1.0.
Yes, if the site owner has set the permalink structure to %postname%, then each post automatically updates the permalink to the post title after they click away from writing the title (replacing all spaces with hyphens).
Currently this is just using the default numerical structure to save the permalink (which means that it breaks the link when published)
+1 for auto update ☺
Hi, I have tested today thanks to @bryanwillis https://github.com/avryl/wp-front-end-editor/issues/173#issuecomment-60351677 and I see that this is not solved. I'm wrong?
Best regards
Can this be closed then?
I just got notified about this because I was linked to another comment I made. Anyway, I don't think we should close this as it's a pretty important factor, in my opinion. We could do something simple using jQuery/javsacript like this...
if (window.location.href.indexOf('?p=') >= 0) {
$('.fee-title').bind('keyup keypress blur', function () {
var myStr = $(this).text()
$('.fee-slug').text(myStr.replace(/(^\s+|[^a-zA-Z0-9 ]+|\s+$)/g, "").replace(/\s+/g, "-").toLowerCase());
});
}
There's probably a better way to do this with php, but I'd have to look take a look at how front-end-editor is overriding the url. Basically we just have to make sure it is a new post because we don't want to auto change the url if the title is changed at a later point (like if it's already published). If wanting to use php we could maybe check for a redirect and parse the url or just check the post status if front-end-editor doesn't have a built in function to check if it's new or not:
<?php if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending' ) ) ) { ?>
<?php }
Also, checking that postname is set before adding the script is probably a good idea:
<?php if ( get_option('permalink_structure') !== "/%postname%/" )
return;
This is gone for now.
Although the permalink does appear, there is no indication that we need to manually edit this in the inline editor.
The result is that, once published, the posts don't appear as their permalink structure is default rather than selected structure. This either needs to auto-update as it does in the backend editor, or needs indication to writers to edit this part too...