Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1331670

    Hello,

    I am trying to add a custom field to the postslider.php file but its not working.

    i have tried
    $stock_availability = get_post_meta( get_the_ID(), ‘stock_availability’, true);
    if ( ! empty ( $stock_availability ) ) {

    echo $stock_availability; // also tried return instead of echo
    $meta_out .= $stock_availability;
    $output .= $stock_availability;
    };

    #1331710

    Hey S-edwards,

    Thank you for the inquiry.

    Where did you add the code in the postslider.php file? You may need to replace the get_the_ID() function with the $the_id variable as shown below.

    $stock_availability = get_post_meta( $the_id , ‘stock_availability’, true);
    

    Best regards,
    Ismael

    #1331772

    Hi Ismael,

    I added it just after the post meta is added. I have pasted the code below for your reference and changed it to get_the_ID but still no luck. I didn’t add the whole file, there is too much code.

    The bit im talking about is right at the end

    #1331803

    Hi,

    Thank you for the info.

    Try to look for this code in the postslider.php file around line 924.

    if( ( $show_meta && ! empty( $excerpt ) ) || in_array( $show_meta_data, array( 'always', 'on_empty_content' ) ) )
    

    Above that line, add this code.

    $stock_availability = get_post_meta($the_id , 'stock_availability', true);
    
    				if ( ! empty ( $stock_availability ) ) {
    					$output .= "<div class='slide-meta-availability'>Availability: ". $stock_availability ."</div>";
    				}
    

    Please check the private field for the screenshot.

    Best regards,
    Ismael

    #1332038

    Thats perfect thanks Ismael, All i need to do now is a little CSS which i can handle.

    thanks for the help, good as always..

    #1332068

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1332714

    hey you can close it thanks, sorry for the delay

    #1332879

    Hi,

    No problem. Let us know if you need anything else. We will close this thread for now.

    Have a nice day.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘add custom field to postslider.php’ is closed to new replies.