• Resolved Film Complet En Francais

    (@film-complet-en-francais)


    Currently URL structure is like this: http://yourblog.com/movies/fight-club

    I want every post URL to have a custom value like this: http://yourblog.com/movies/fight-club-value

    I can achieve this for default wordpress posts by changing permalink structure in wordpress settings: http://yourblog.com/%postname%-value/
    But obviously it doesn’t work for WPMovieLibrary movie posts. I was looking through plugin files but couldn’t figure this out. Any help appreciated.

    https://ww.wp.xz.cn/plugins/wpmovielibrary/

Viewing 15 replies - 1 through 15 (of 19 total)
  • Hi there,

    It can’t work on movies indeed as most of the permalink structures are hard-corded in the plugin. That’s kind of poorly handled and we’ll fix this in version 2.0.

    In the meantime you can edit the plugin’s rewrite rules in the register_permalinks() function of the includes/class-wpml-utils.php file and add you custom value to the regular expressions you want. Don’t forget to reload the dashboard’s “Permalinks” page so the changes are effective!

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Unfortunatelly, I don’t understand PHP at all. Can you tell me which line I am supposed to edit?

    Sure, please try changing line 122 from:

    $movies . '/([^/]+)/?$' => 'index.php?movie=$matches[1]',

    To:

    $movies . '/([^/]+)-your_value/?$' => 'index.php?movie=$matches[1]',
    $movies . '/([^/]+)-your_value(/[0-9]+)?/?$]' => 'index.php?name=$matches[1]&page=$matches[2]',
    $movies . '/([^/]+)-your_value/page/?([0-9]{1,})/?$]' => 'index.php?name=$matches[1]&paged=$matches[2]',

    Let me know how this works!

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    For some reason, it didn’t work. My already published movies started getting 404 Page Not Found and new ones still had the same old permalink structure without custom value added.

    It does work on my test installations; did you reload the Settings > Permalinks page to apply the change?

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    I did reload Permalinks page it had no effect. Tried it on 2 different WordPress installs and still didn’t work.
    By the way, the code I have to change is on line 120 in my version of the plugin. I use v1.2.2.

    Server info:
    Apache version 2.2.29
    PHP version 5.3.29
    MySQL version 5.5.36-cll-lve

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    I hope v2.0 is not too far away. I really need this fixed as soon as possible.

    I’m afraid there’s still some work to do on v2.0 before we can think of delivering a stable release…

    Here’s an edited v1.2.2 class-wpml-utils.php thats works everywhere I tested it, see if it works for you: https://gist.github.com/CaerCam/1e0f68c36ab45f060df3 Edit your custom value at line 113.

    Note: this should only make the links work with or without the suffix; to generate permalinks including your suffix, add this to your theme functions.php file: https://gist.github.com/CaerCam/773f048663082e4c4b00

    That being said, from I just saw of your website the suffix seems to work, doesn’t it?

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    I added suffixes manually. I want URL to include my suffix automatically when creating a new movie post. I’ll try your suggestions.

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Now it seems to be working! It doesn’t show suffix added in dashboard when creating a movie post, but when movie is published it has suffix added. Thanks for helping me out!

    Don’t mention it! I noticed the suffix doesn’t show in the post editor, this is really a quick as I have virtually no idea on how to apply to movies the same rewrite rules as regular posts… That’s something I’ll be looking for to learn and implement in v2 πŸ™‚

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Maybe this is a stupid question, but what is the reason why this plugin uses custom post types? Using regular wordpress posts would solve many compatibility problems and would work with any theme out there. It would be nice to have an option to just import movie information in to regular wordpress post.

    That’s no stupid question; the simplest answer is that it makes it easier to develop and use in numerous ways. There are tools inside WordPress that make it much easier to use custom post types rather than regular posts you would have to constantly separate from movies before doing anything; using a CPT you can target actions on this post type only and leave all other post types aside, affect custom taxonomies to this CPT only, define metaboxes, etc…

    The compatibility issue in another part of the problem, but I tend to see it the other way: more often than not, compatibility issues come from themes that doesn’t support custom post types or handle them poorly; but since the plugin uses regular WordPress techniques, every theme should work smoothly with it. Technically CPT are in all points similar to regular posts, except for the post_type field in the database that’s set to ‘movie’ instead of ‘post’; it’s really easy for theme developers to adapt, but obviously a lot of them just don’t think about it when working on a theme.

    All considered, it is much more easier and cleaner to use a custom post type, even though compatibility with some themes can require a few tweaks πŸ™‚

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Thanks for your clear explanation, now I understand about WordPress a bit more.

    Thread Starter Film Complet En Francais

    (@film-complet-en-francais)

    Hi,
    I’m a bit lost. How can I apply these changes to current plugin version?

Viewing 15 replies - 1 through 15 (of 19 total)

The topic ‘Custom URL’ is closed to new replies.