#79077 Displaying custom fields via functions.php

Landing Forums Jupiter WordPress Theme Displaying custom fields via functions.php

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • Anitas Organic

    Hi! I am in the process of switching a plugin on our site which displays recipes over to a new, revamped version. As a result of this, certain custom fields for the recipes, whose entry and display used to be entirely handled by the plugin, will now need to be added, via extra code, to each recipe post’s layout. (The recipes used to be custom posts and now are just regular posts.)

    Most pages/posts on the site are built in Elementor, but not the recipes – they’re just plain posts, so I believe I need to make an adjustment to the Jupiter theme. (We’re using a child theme.)

    So I think I can achieve this with some code in functions.php – but I’m at a loss as to how I would exactly, correctly do this.

    I found this article on your support site: https://themes.artbees.net/docs/adding-custom-fields-to-a-single-blog-post/

    And I was thinking I might use something along the lines of

    add_action( ‘jupiterx_post_image_before_markup’, function() {
    echo the_field(‘related_recipes’);
    } );

    BUT… that’s for jupiterX, not jupiter; and I don’t know where I actually need to add the action to. Or if this method would even work for Jupiter vs. JupiterX. I combed through the theme but couldn’t find any files that showed layout shortcodes along the lines of “post_image_before_markup” etc.

    Can you advise on how I would add custom field content to posts of a certain type (i.e. just the recipe layouts)?

    Just to give you all the info, I need to add:

    related_recipes
    tips_techniques
    related_products

    In that order, directly after the recipe (i.e. the post content), and before tags/comments.

    Thanks!
    Adam

    PS – The credentials I’m supplying are for a staging site, which I just set up for this purpose. I assume any solution will be exactly the same for the live site though.

    Private
    Anitas Organic
    This reply has been marked as private.
    Anitas Organic

    Hi again. I’m sure you guys are busy but is there any chance of looking into this soon? I only have 2 more days to fix this and it has been 2 days since I posted.

    Thanks,

    Adam

    Tatyana Hutsol Support Team

    Hello,

     

    Sorry for a delay.

    I have updated the post and the sidebar is shown: http://6bx.207.myftpupload.com/cakes/nectarine-plum-crumb-cake/ .

    Try to update other posts where sidebar is invisible.

    Did you create receipt posts with some custom plugin for custom post types?

    As I see you have the plugin Advanced Custom Fields. You can use it to add custom fields to your custom post type:

     

    Thank you.

    Regards.

    Anitas Organic

    Thanks Tatyana! I never suspected that simply opening up the recipe and updating it would fix the sidebar issue, that’s fantastic.

    As for the custom fields, I think I’ve got that just about figured out, but thanks for your suggestion.

    Adam

    Anitas Organic

    One last thing though – in the previous layout, the areas for “related” content, plus the Comments section, were full-width at desktop view:

    For the revamped layout, I was able to add the Related content here:

    /wp-content/themes/jupiter-child/views/blog/components/blog-single-content.php

    But I see that both it, and the comments, are held to the same width as the recipe (i.e. all the post content):

    To get them both to expand to full page width, do I need to place code for both of them in a different theme component file? Can you advise?

    Many thanks!

    Adam

    Anitas Organic

    Hi again! Just following up with a bit more info. It looks like what I need to do is modify my child theme so that my custom table with “related” info (which is now in jupiter-child/views/blog/components/blog-single-content.php), as well as the entire comments section, both get displayed after (and totally outside of) the divs for the page’s main content and that for the sidebar (.mk-main-wrapper, and #mk-sidebar).

    That seems to be the only way to allow them to expand to full page width.

    I tried adding a test DIV to this file:

    jupiter-child/components/shortcodes/mk_page_section/components/layout-structure__full.php

    But it’s not showing up at all on my recipes:

    6bx.207.myftpupload.com/cakes/lemon-scented-cupcakes-with-lemon-curd-lemon-frosting/

    So I’m assuming I’m in the wrong place.

    Can you advise? Thanks!

    Tatyana Hutsol Support Team

    Hello,

     

    Sorry for a delay.

    Can you provide FTP credentials to check your modifications?

     

    Thank you.

    Regards.

    Private
    Anitas Organic
    This reply has been marked as private.
    Private
    Anitas Organic
    This reply has been marked as private.
    Tatyana Hutsol Support Team

    Hello,

     

    Sorry for a delay.

    Could you please update the theme to the latest 6.7.0 version on your live site?

    At first deactivate WPBakery plugin and update Jupiter:
    https://themes.artbees.net/docs/updating-theme-child-theme/ (read the part “Updating theme via FTP”)

    How to get Jupiter 6 archive, read here:

    ​Then install Jupiter Donut and Jupiter Core plugins via Jupiter > Control Panel > Required Plugins.
    Then activate WPBakery plugin and update it via Jupiter > Control Panel > Required Plugins.

    Let us know the result.
    Thank you.

    Anitas Organic

    Thanks so much, I will give that a try and let you know!

    Tatyana Hutsol Support Team

    You’re welcome!

     

    Regards.

    Anitas Organic

    Hi Tatyana! So I successfully updated everything, and the site’s working fine, but that alignment issue is still there on the live site:

    https://anitasorganic.com

    What do you suggest? It’s strange that the bottom of all boxes are still lined up perfectly on the staging site:

    http://6bx.207.myftpupload.com

    Let me know what you recommend… thanks!

    Adam

    Mohsin Al-Rabieai Support Team

    Hi Anitas,

    Please accept my sincere apologies for the delay. The reason that your images in the blog teaser are not aligned is that they don’t have permission to be resized as they are still being served over a CDN and even the image address is pointing to your previous domain. They can only be resized if they host on the same domain. So, while this is the image address in one of the blog teaser items:

    https://secureservercdn.net/198.71.233.96/i2x.979.myftpupload.com/wp-content/uploads/2019/09/caramel-apple-crumble-slices-anitas-organic.jpeg?time=1600840404

    If the image address was like this:

    https://anitasorganic.com/wp-content/uploads/2019/09/caramel-apple-crumble-slices-anitas-organic.jpeg?time=1600840404

    Everything would be fine. I recommend you to deactivate your CDN once, then use the “Better Search and Replace” plugin to replace all the old URLs with the new domain This should resolve the issue.

    Hope it helps 🙂

Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login