• Resolved nikhilazza

    (@nikhilazza)


    I want to add a meta description line below the site title using the single.php

    The description is called from meta tags of Rankmath using echo get_post_meta($post->ID,'rank_math_description',true);

    For example – https://www.digitbin.com/find-if-image-is-edited/ The post has a small meta description from rank math using the above code.

    https://prnt.sc/197suur

    I used inc/views/post_layout.phpin the theme editor to add the above code below the post title/above-featured image but no results, please help.

    • This topic was modified 3 years, 8 months ago by nikhilazza.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi @nikhilazza,

    Thank you for reaching out and using the Neve theme.

    I won’t suggest you edit the theme files to add a custom code, it will be lost when you update the theme.

    Usually, the most recommended way to use a custom code with the theme is by?using a child theme. A custom child theme is an?extension?of your original (parent) theme where you can modify theme files and CSS code very easily.

    Please create a child theme for Neve using this guide and add the following code in the functions.php file of your child theme to show the meta description from rank math below the title of the post.

    function show_rank_math_description_neve(){
    	echo RankMath\Post::get_meta( 'description', $post->ID );
    }
    add_action('neve_post_meta_single', 'show_rank_math_description_neve');

    Hope it helps.

    Thread Starter nikhilazza

    (@nikhilazza)

    Hey Poonam,

    Thanks a ton! This worked like a charm. I am not much into PHP, so can you please add code to make the description look a little bold and also italics.

    Regards,

    Hi, @nikhilazza!

    To show the description in bold and italics, the code provided above will be slightly changed so it will look like below.

    function show_rank_math_description_neve(){
    echo “<b><i>”;
    echo RankMath\Post::get_meta(‘description’, $post->ID );
    echo “</i></b>”;
    }
    add_action(‘neve_post_meta_single’, ‘show_rank_math_description_neve’);

    Have a wonderful day!

    Thread Starter nikhilazza

    (@nikhilazza)

    Thanks, Mate! Neve Theme and Team Both are Superb!

    We are glad your issue is solved!

    Thank you and have a wonderful day!

    Hi,

    Do you know how to display custom field instead of meta description below the site title?

    I’m using Advanced Custom Field but can’t make it work.

    Thanks.

    • This reply was modified 3 years, 5 months ago by geraeldo.

    Hello @geraeldo!

    Thanks for choosing Neve!

    Displaying the value of a custom field added with the Advanced Custom Fields plugin on the front end is possible in the premium version of the theme, using the Custom Field widget.

    Have a nice day!

    Hi @luciamarinescu

    Thanks for your reply.

    Yes, I’m using Neve Pro but can’t seem to find a way to insert custom field just right under the h1 title of a blogpost. It should be between the title and post meta.

    Do you know how to do that?

    Thanks a million!

    Hello @geraeldo!

    You can find a detailed guide on how to add custom fields in the Pro version of the theme with the Advanced Custom Fields plugin and the Custom Field widget here.

    I hope this helps!

    As you use the premium version of the theme, please contact us by opening a ticket directly on our site for any other questions you may have in the future. This way we will be able to help you quicker and more efficiently.

    Have a good day!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to Add a Custom meta in single.php?’ is closed to new replies.