lundi 23 mars 2015

Custom field not updating via functions upon publishing


I've created the code so that on publish of the page, the custom field 'bookinfo' in the page is automatically generated but its not doing anything


Below is my code in in functions.php:-



<?php
if (is_page()){

function generate_page_html( $page_id ) {

$title=get_the_title();
$link=get_the_permalink();
$booktxt='new book'.$title.'at'.$link.'grab quickly';

update_page_meta( $page_id, 'bookinfo', $booktxt);
}

add_action( 'save_page', 'generate_page_html' );
}
?>


P.S i am using advanced custom fields to create the custom field where the rule is to display the field group of posttype is page





Aucun commentaire:

Enregistrer un commentaire