• Resolved rjdrijvers

    (@rjdrijvers)


    Hey there,

    Amazing plugin! I am currently working on a website for our architecture firm in my free time, and I was wondering if there is an easy way to manipulate the permalink structure.

    What my situation is, a project link for example would look like:
    https://website.com/portfolio/villa-amsterdam/

    And I want it to look like:
    https://website.com/project/villa-amsterdam/

    I have experience with PHP, but not so much with WordPress. I figured there might be a file that held all the permalink generator in it, where I could manipulate it, but I can’t seem to locate it… Is there any chance this can be done semi-easily? I’ve tried working with the WordPress Admin panel (settings > Permalinks) but I can’t seem to get it to work ??

    The same goes for the permalink structure on category pages, they currently look like:
    https://website.com/portfolio/category/interior/

    But I would love for them to be able to be manipulated into just:
    https://website.com/interior/

    Basically making it a lot cleaner and friendlier, since the entire website would be based on a slideshow frontpage, different categories (showing as portfolio category pages) for different projects, and a few static pages containing info.

    This plugin literally has everything to build an amazing website out of; if these small permalink things could be possible I would be very grateful, since our website would be complete ??

    Thanks ahead and thanks for the plugin!

    Rob

    ninja-edit: is there a way to re-order existing entries?

    • This topic was modified 7 years, 2 months ago by rjdrijvers.
    • This topic was modified 7 years, 2 months ago by rjdrijvers.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter rjdrijvers

    (@rjdrijvers)

    After some more searching I found how it’s done; through the Photography_Portfolio/Core/Register_Post_Type.php file.

    So I managed to get the first rewrite done, rewriting the slug “portfolio” into “project” but I can’t seem to figure out how to do the second one; changing ‘portfolio/category/interior’ into just ‘interior’… I’m simply not experienced enough with WordPress to get these simple arguments done ?? I’ve tried to go through the documentary, but it’s hard for somebody who just started with WordPress ??

    If I could still get some help with the category URL issue, that would be awesome! <3

    Plugin Author justnorris

    (@justnorris)

    Don’t remove the slugs completely. It’s probably going to break something.

    But you can modify them. That’s why I’ve added the filters phort/post_type/args phort/taxonomy/args. You can edit the arguments passed to the register functions before they’re called. Just make sure you add the code in somewhere you control (either your own plugin or in functions.php file in your theme, if it’s your custom made theme, otherwise make your own plugin) – otherwise you’ll loose any changes each time you update the theme or the plugin. “Not Updating” is also not a good option.

    Use filters to edit the settings. You can read more about registering post types and taxonomies here:
    https://codex.www.ads-software.com/Function_Reference/register_post_type
    https://developer.www.ads-software.com/reference/functions/register_taxonomy/

    And about add_filter function here:
    https://developer.www.ads-software.com/reference/functions/add_filter/

    If you know just a little bit of PHP you’ll be able to figure it out.

    p.s. After you modify anything related to the URL rewrite – you have to reset your permalinks by changing the permalink structure twice (change to a different, save changes, then change it back)

    • This reply was modified 7 years, 2 months ago by justnorris.
    Thread Starter rjdrijvers

    (@rjdrijvers)

    After going through the references, I figured out that it cannot simply be removed (basically what I want), since any URL will result in WordPress looking for portfolio entries that match that specific request. I could however make it work with some .htaccess or add_rewrite_rule() work, but it could collide with other pages/plugins in the future.

    I’ll just have to make it look pretty by using a slug that fits the page, which is 99% perfect anyways ??

    Also thanks for the tips regarding updating the themes and plugins!

    Have a good day

    Plugin Author justnorris

    (@justnorris)

    By the way,
    If you like the plugin, please consider adding a review here on WordPress. That would help me out a lot! https://www.ads-software.com/support/plugin/photography-portfolio/reviews/?filter=5

    And a good day to you too ??

    Thread Starter rjdrijvers

    (@rjdrijvers)

    Just make sure you add the code in somewhere you control (either your own plugin or in functions.php file in your theme, if it’s your custom made theme

    So basically I have been messing around with this, trying to get it to work without touching the plugin itself (by adding code to functions.php in my custom theme). Again however, I am having trouble by adding the code. I’ve tried several things regarding copying the parts of the Register_Post_Type.php file into functions.php and editing them before letting them get submitted to WordPress.

    In all honesty, I have no idea what I’m doing. I’ve spend quite some hours on this now, but for WordPress wizardry I feel like there is not enough experience with PHP for me (or simply experience with WordPress it feels like).

    In my head, it firstly activates the WordPress core, then the plugins, and then it looks at theme files? I could be wrong on that though. This however would mean that I could overwrite the plugin’s ‘register_taxonomy’ by creating an edited version in functions.php? But that is not working..

    When asking for help I rarely ask for direct code to add, but I am left clueless on this one. If you could show me how to do this with my theme’s functions.php, I would be a very happy man.

    Thanks ahead!

    ps: I’ve tried to look into your other suggestion: creating a custom plugin to overwrite EPP, but that leaves me with more questions then my original one.

    Plugin Author justnorris

    (@justnorris)

    In your themes functions.php file:

    
    add_filter(
    	'phort/post_type/args',
    	function ( $args ) {
    		$args['rewrite'] = [ 'slug' => 'foobar' ];
    		return $args;
    	}
    );
    

    That function is going to take all the already defined $args, modify them and return them back to Easy Photography Portfolio. You can do the same thing with the phort_category if you want to. That’s how you use hooks.

    As for where to put it – actually the best place if you don’t want to make a plugin is to create a child theme ( there are even plugins that can generate a child theme for you ) – that way you can update the theme you’re using in the future, but child theme files won’t be touched – all you need to put in that child theme is a plain functions.php file – everything else will still be done by the parent theme.

    I hope that cleared things up for you :).

    Thread Starter rjdrijvers

    (@rjdrijvers)

    That definitely cleared things up for me. That little piece of code made me understand more of how WordPress does things using hooks (as to what post_types and taxonomy are, how there are registered and how to manipulate them).

    I built my own custom theme around Underscores (_s) with some other libraries, so I assume I can skip the child theme/plugin step and just use the themes functions.php.

    So if I wanted to manipulate the way the category pages are displayed, as in change the way you hover over them and basically the entire css styling of them (I have styled my own setup), how would I go about doing that? I assume there is a ‘hook’ to overwrite the templates in EPP and use my own template files? Or would that break things once the plugin is updated and uses different variables/new functionality?

    Thanks! ??

    • This reply was modified 7 years, 2 months ago by rjdrijvers.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Changing permalink ‘portfolio/’ to ‘project/’’ is closed to new replies.