Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #272343

    michele
    Participant

    hi – I wondered if this was possible.
    The portfolio item page is not what I need for my design as really want the portfolio items displayed on my portfolio page to go directly through on a click to a page/post.
    Maybe its easier if I try and explain this way – if I have a portfolio page called ‘places to eat & drink’ so that underneath visitors to the site could sort by coffee shops, restaurants and hotels say (these would all be child portfolio items from parent ‘places to eat & drink’) When a visitor clicks on the portfolio item (say coffee shop1 – which I would also set up as a portfolio item) they would go straight through to say a post page (called coffee shop 1 too – which I would build as a post or page in itself) Is this possible? Its just I really don’t want visitors having to do too many clicks – if they could choose say a coffee shop and go straight through to it it would be better.
    Is there a way to do this?
    Many thanks for your ongoing support – I really do appreciate it.
    Michele

    #272388

    michele
    Participant

    Aaagh – I found this article on the forum and thought it would be the answer to what I was asking you above, but when I tried to add the code in my x child functions.php file I managed to break it – getting an error message – Parse error: syntax error, unexpected end of file in /home/phil08/public_html/wp-content/themes/x-child/functions.php on line 1. So I went back to the file and deleted the code I added and uploaded to site again, but still getting error message and cant access my site at all. Can you please help?
    Michele

    This was the code I added and then removed:
    I’m sorry, the portfolio items can’t be given page templates and made full width. You can however, create separate pages for each item.

    In your portfolio items, you can set a “Project Link” and place a link to the page you created. This is usually meant for linking to an external source

    Next, add this to the functions.php of your child theme.

    This code will make that portfolio item directly link to the “Project Link” instead of the portfolio item page.

    add_filter( ‘post_type_link’, ‘x_remap_portfolio_permalink_to_project_link’, 10, 4);

    function x_remap_portfolio_permalink_to_project_link($post_link, $post, $leavename, $sample) {

    if (‘x-portfolio’ == $post->post_type) {
    $custom = get_post_custom($post->id);

    if (isset($custom[‘_x_portfolio_project_link’]) && $custom[‘_x_portfolio_project_link’][0]!=”)
    return $custom[‘_x_portfolio_project_link’][0];
    }

    return $post_link;
    }
    EDIT: I’d like to add a bit more info here, as this workaround has been referred to in other topics.

    The code above will change the link of the portfolio items. So when you click an item from the portfolio page, it will send you directly to the custom link. This helps if you want a more unique layout that can only be created using a page, or if you want an external link directly.

    After adding the code, you should do this:

    1. Create your portfolio items.
    2. For each portfolio item, create a new page to present the unique layout you would like.
    3. After creating a page, view it, and copy the link
    3. Edit the portfolio item, and paste the link into the “Custom URL” field.

    Now when you view the portfolio page, clicking an item will send you directly to the set URL.

    #272403

    michele
    Participant

    Ok, so I have managed to get access to my site and all ok – I unzipped my childxtheme on my computer and uploaded the original funtions.php file to my website , so everything is back to normal 🙂

    But, can you still help me with my original question? Will the above code work to do what I want to do, and if so , could you show me exactly where to place it in the child theme functions.php file to make sure I do it correctly?
    Many thanks and sorry for such a long thread of questions.
    Michele

    #272595

    Zeshan
    Member

    Hi Michele,

    Thanks for writing in!

    Do you wish to redirect your single portfolio item page to another URL? If so, you can review this thread: https://theme.co/x/member/forums/topic/directing-an-item-in-portfolio-to-a-page/#post-36075

    Thanks!

    #272615

    michele
    Participant

    Hi I tried to do the above, added the code, built a page called
    http://www.bestofourshire.com/sierrra-farm-test-page/
    and then added the custom field code under the portfolio item sierra farm
    http://www.bestofourshire.com/wp-admin/post.php?post=20&action=edit
    adding the code x_custom_link and http://www.bestofourshire.com/sierrra-farm-test-page/

    so, when you go to the portfolio page and click on the portfolio item sierra farm it still goes back to the portfolio item as opposed going to the test page I created. Have I done something wrong? I need the permalink on the front of the item on the portfolio page to go directly to another page, not go to the portfolio item first.

    Does that make sense?
    Michele

    #272673

    michele
    Participant

    In other words, I need to find a way of going from here
    http://www.bestofourshire.com/wp-admin/customize.php?return=%2Fwp-admin%2Fpost.php%3Fpost%3D20%26action%3Dedit
    and by pressing the little pink link on front of sierra farm to go to
    http://www.bestofourshire.com/sierrra-farm-test-page/

    therefore cutting out the visit to the single portfolio item page.
    Is this possible?
    Thank you in advance
    Michele

    #272871

    Nabeel A
    Moderator

    Hi Michele,

    The Code provided in this post https://theme.co/x/member/forums/topic/directing-an-item-in-portfolio-to-a-page/#post-36075 works just fine. I have tested it on my localhost and it’s working just as expected. You might have missed something. Try re-pasting the code again carefully in your child theme’s functions.php file then you will need to create a custom field to add the custom link. Make sure you save the custom field. Once it’s done it will work properly.

    Let us know how this goes!

    #272904

    michele
    Participant

    Where do I paste the code – could you show me incase I am adding it incorrectly?
    Do I paste above the existing code or below?
    And can you clarify, will this code take me straight from the portfolio page showing all the portfolio items straight to the page that is set up, via the permalink, without going via the portfolio item page?

    thank you
    Michele

    #273125

    Friech
    Moderator

    Hi Michele,

    Just append that code on the bottom of your child theme’s functions.php file

    image

    Then do this on the portfolio’s custom field

    image

    Yes, it should directly link to the relative link you assigned on custom field.

    Hope this shed some lights. Cheers!

    #273248

    michele
    Participant

    Many thanks for clarification – I will try again and let you know how I get on… 🙂
    Michele

    #273275

    michele
    Participant
    This reply has been marked as private.
    #273303

    Rad
    Moderator

    Hi there,

    Are you sure it was added at your child theme’s functions.php? I can’t find it there. Perhaps you forgot to upload your functions.php?

    I’d like to do that but applying custom code should be done through FTP only. Else it may break your site when something bad happens.

    Please try it again, Thanks!

    #273328

    michele
    Participant
    This reply has been marked as private.
    #273338

    Rad
    Moderator

    Hi there,

    In that case, you should contact your hosting. It looks like file system related issues, and your FTP is failing to write your changes.

    Thanks!

    #273346

    michele
    Participant

    Thank you I worked it out – i had 2 functions.php file on my computer and editing the wrong one. ANyway, now it seems to be working which is great. But can I ask just one more question on this? So say someone looking for ‘the kilted grog’ on google. I would want my page http://www.bestofourshire/the-kilted-grog to show up rather than the portfolio item page – would the portfolio item page show in google?
    Many thanks for helping sort this out,
    Michele