Permalinks On Custom Post Type

Home Forums Jevelin Theme Permalinks On Custom Post Type

Home Forums Jevelin Theme Permalinks On Custom Post Type

Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
  • edugsdf
    Participant

    I define the structure of permanent links like this:
    http://meusite.com.br//blog/%<wbr />postname%/
    But the portfolio links looks like this:
    http://meusite.com.br/blog/roteiro/nome-do-post
    How to make custom post types permanent links do not inherit “/ blog /” and look just like this:
    http://meusite.com.br/roteiro/<wbr />nome-do-post

    See attached image

    Attachments:
    You must be logged in to view attached files.

    Hi @edugsdf,

     

    I hope you are well today and thank you for your question.

     

    Your shared URLs are not accessible at all.

     

    Also have you tried change it in the permalink settings as shown in the attached screenshot?

     

    Best regards,
    Shufflehound team

    Attachments:
    You must be logged in to view attached files.

    edugsdf
    Participant

    Hello!
    I already changed. See the attached screen for the previous question. And that part is working right.

    Custom post type inherits the permantente links from the common settings.
    In my common settings it looks like this:
    /blog/%postname%/

    For blog is correct, because the link in the browser looks like this:
    http://mysite/blog/name-of-post

    But for Custom post type portfolio the URL in the browser looks like this:
    http://mysite/blog/roteiro/name-of-post

    I want to remove the “/ blog” when it is custom post type. And final URL should look like this:
    http://mysite/roteiro/name-of-post

     

    I was researching how to change, and found this link:

    https://paulund.co.uk/flush-permalinks-custom-post-type

    But in the source code of thema I did not find where does the post type record …. that should be so “register_post_type”.

     

    Another solution is to use the post_link filter to modify the links, but for this I will need to include code in functions.php and with certainly in a thema update I would lose all the code.

     

    How can you help me?

    Attachments:
    You must be logged in to view attached files.

    You can try using below plugin to change custom post type permalink.

     

    https://wordpress.org/plugins/custom-post-type-permalinks/

    edugsdf
    Participant

    The plugin did not solve the problem. But he pointed out the cause.

    See in the attached image, the markings in blue frame.
    The Custom Post Types “product” creates the link correctly because it uses with_front to false.

    See, fw-portfolio uses with_front to true. And for that reason it adds “/ blog /” to the URL.

    See attached image of woocommerce, where in the source code it uses correctly.

    Just this correction. But I did not find it in your source code to make this change.

    Can you tell me how to fix this?

    Attachments:
    You must be logged in to view attached files.

    edugsdf
    Participant

    Searching more closely, I discovered that you register custom post type in the unyson framework.

    So I made a small change there and it worked. Attached follows the screen where I made the change.

    But now I have a concern …. when there was a new update, I will lose all this.

     

    What do you suggest me ?

    Attachments:
    You must be logged in to view attached files.

    edugsdf
    Participant

    Missing one more parameter. Here are the two complete parameters:

    ‘with_front’ => false,
    ‘hierarchical’ => true,

     

    Instead of making changing in the plugin file that get lost after plugin updation, you can use registered_post_type hook in the functions.php file of child theme or in the custom plugin to modify fw-portfolio custom post type parameters as described on the following page.

     

    http://wpsmith.net/2013/use-registered_post_type-hook-to-modify-post-type-registration/

    edugsdf
    Participant

    I’m suggesting an improvement for thema.

    Because the way it was implemented is this “wrong”. Take the Custom Post Type products from woocommerce as an example. It did it correctly and it works without me having to change anything.

    This improvement will not affect anything in thema and will still work better. Because custom Post Type is not part of the BLOG structure.

    Actually it is a part of Unyson plugin so as a theme developer we can not make direct changes in it but we will suggest plugin developer to do it.

    In the meanwhile the best way for you is to use hook as i have described above.

    edugsdf
    Participant

    Thanks for suggesting the change to the developer.

     

    But I have a question.
    This file (/wp-content/plugins/unyson/framework/extensions/portfolio/class-fw-extension-portfolio.php) was created by unyson and not by you?

    Yes whatever files created in directory /wp-content/plugins/unyson/ is created by Unyson plugin and not Jevelin theme.

    edugsdf
    Participant

    OK. Because of the name I imagined it was created by you.

     

    Is the code using hook to modify custom post type added in the functions.php file of thema?

    Is the code using hook to modify custom post type added in the functions.php file of thema?

    No

    edugsdf
    Participant

    Can you guide me where to put this code?

    You can add it in the functions.php file of Jevelin child theme or develop small custom plugin and add it in that plugin file.

    edugsdf
    Participant

    OK. Thank you!
    I’ll try to use the theme child.

    Just install it normally as if it were a thema. Right?

    Yes install and activate it. Here is more information about child theme http://freewptp.com/why-and-how-to-create-wordpress-child-theme/

    edugsdf
    Participant

    I was able to change the custom post type using the child thema.
    But using the link method (http://wpsmith.net/2013/use-registered_post_type-hook-to-modify-post-type-registration/) you indicated did not work well.

     

    The code I used, was this:

    add_action( ‘init’, ‘edu_remove_prefix_blog‘, 999);
    function edu_remove_prefix_blog() {
    $obj = get_post_type_object(“fw-portfolio”);
    $obj->rewrite[“with_front”] = false;
    $obj->rewrite[“hierarchical”] = true;
    register_post_type($obj->name, $obj);
    }

    Can you tell me if it was the right form? If not it will overload my site.

    It seems right.

Viewing 20 posts - 1 through 20 (of 20 total)