Job Posting Meta Display in PHP

#73102
  • Resolved Puneet
    Rank Math free

    Hi,
    I want to print Job posting data on the archive page, For example I want to display Title, Description, Last Date, Organization, and Salary in a single Job Archive card so how it possible?
    It is possible as we display Breadcrumb by PHP in backend single.php file.
    Like we use <?php if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); ?> to show breadcrumb, so like
    this code how to display Job Posting Data (Above Mention data which I want to use in archieve.php) that we created in Single Posts.
    Thank You

Viewing 15 replies - 1 through 15 (of 28 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    What do you mean with the “Job Posting card”? Could you share a screenshot showing us where you would like to display that information?

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Puneet
    Rank Math free

    I mean all the information that we fill in job posting fields is displayed in Google Jobs SERP. So like that, I want to display similar data in the archive page using job posting data.
    I want to use Title, Description, Last Date, Organization, and Salary, Job Type fields instead of Category, Comment, Admin, Date, fields in the archive.

    How can I print data of rank math job posting fields in PHP?

    serp-job
    srchieve

    Hello,

    We are so sorry but it is not possible with Rank Math. You may have to custom code that or hire a developer that can do it for you.

    Puneet
    Rank Math free

    I can do it, if you provide me code by which job posting values stored and execute in the Head.

    Alberto
    Rank Math business

    Hello,

    You could try using https://wordpress.org/plugins/jsm-show-post-meta/ and looking for the meta fields you need.

    After that, using the https://developer.wordpress.org/reference/functions/get_post_meta/ you could access each post meta fields and print them as you want.

    Looking forward to help you.

    Puneet
    Rank Math free

    It works but results are as follow:

    • <?php $item = get_post_meta($post->ID, ‘rank_math_snippet_jobposting_organization’, true); ?>
      <?php print_r( $item ); ?>
    • Output – Google India [Result As I want to display]
    • <?php $item = get_post_meta($post->ID, ‘rank_math_snippet_jobposting_address’, false); ?>
      <?php print_r( $item ); ?>

    • Output – Array ( [0] => Array ( [streetAddress] => Noida, New Delhi [addressLocality] => New Delhi [addressRegion] => New Delhi [postalCode] => 110001 [addressCountry] => India ))
    • I want to display only Noida, New Delhi {StreetAddress} & 110001 {PostalCode}
    Alberto
    Rank Math business

    Hello,

    I think you will need then to process the var before printing them in your HTML. Maybe using some code to just select a part of the text you want from the returned array.

    Looking forward to help you.

    Puneet
    Rank Math free

    Can you provide me exact code or where to use var?

    Alberto
    Rank Math business

    Hello,

    For this one: “Output – Array ( [0] => Array ( [streetAddress] => Noida, New Delhi [addressLocality] => New Delhi [addressRegion] => New Delhi [postalCode] => 110001 [addressCountry] => India ))”, you can use this code:

    <?php $item = get_post_meta($post->ID, ‘rank_math_snippet_jobposting_address’, false);
     print_r( $item[0]["streetAddress"] ); ?>

    Looking forward to help you.

    Puneet
    Rank Math free
    <?php $item = get_post_meta($post->ID, 'rank_math_snippet_jobposting_address', false); ?>
          <?php print_r( $item[0]['streetAddress'] ); ?>
    • This is works perfectly but I don’t know why it’s not working when use print_r command in single tag?
    • i use multiple lines to print streatAddress and pinCode, how to print in single array? like print_r( $item[0][‘streetAddress’][‘postalCode’] );

    Q. 1How to display expiry date? When call ‘rank_math_snippet_jobposting_expirydate’ it’s display 1596844800 for 2020-08-08 12:00 AM
    Q. 2Is it possible to display automatically post publish date at jobposting’s Date Posted section?
    Thank You

    • This reply was modified 4 years, 4 months ago by Puneet.
    Alberto
    Rank Math business

    Hello,

    About question 1, databases usually store dates as seconds from 1970, you should convert it to current date, you can read about it here: https://www.w3schools.com/php/func_date_time.asp

    About question 2, I am not sure to understand your question, could you give us more details?

    Looking forward to help you.

    Hello,

    You can customize the following filter:

    
    add_filter( "rank_math/snippet/rich_snippet_jobposting_entity", function( $entity ) {
     $entity['datePosted'] = get_the_date( $format,$post_id );//replace with date format and postid
     return $entity;
    }, 99 );
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Puneet
    Rank Math free

    Yes, it works perfectly.
    Now can we automatically print the last date also because most posts are valid for 30 days?
    So I want to print the last date [with 30 days validity from post publish date] automatically.
    For Example – New post is published on 2020-08-02T12:00 so after using the above code rank math default print Date Posted – 2020-08-02T12:00, but the Valid date must be 2020-09-02T12:00.

    Puneet
    Rank Math free

    Hi, I have now just checked my posts, this code is print today’s date on the whole website’s job posting section.

    // Rank Math Job posting Date
    add_filter( "rank_math/snippet/rich_snippet_jobposting_entity", function( $entity ) {
     $entity['datePosted'] = get_the_date( date("Y-m-d H:i:s"),$pot_id );
     return $entity;
    }, 99 );

    Hello,

    You will need to assign the post id value of the post to get date published then assign it to the $post_id variable.

    For the validity you can use $entity['validThrough']= //get post date plus 30 days.

    Hope that helps

Viewing 15 replies - 1 through 15 (of 28 total)

The ticket ‘Job Posting Meta Display in PHP’ is closed to new replies.