Have function add variables/values to the $post object?
-
How do I add
$tzDescand$tzEmbed(and other variables) to the $post object in the following function so that I can display the values in my theme files by inserting<?php echo $tzDesc; ?>?add_action( 'the_post', 'paginate_slide' ); function paginate_slide( $post ) { global $pages, $multipage, $numpages; if( is_single() && get_post_type() == 'post' ) { $multipage = 1; $id = get_the_ID(); $custom = array(); $pages = array(); $i = 1; foreach( get_post_custom_keys() as $key ) if ( false !== strpos( $key, 'slide' ) ) $custom[$key] = get_post_meta( $id, $key, true); while( isset( $custom["slide{$i}-title"] ) ) { $page = ''; $tzTitle = $custom["slide{$i}-title"]; $tzImage = $custom["slide{$i}-image"]; $tzDesc = $custom["slide{$i}-desc"]; $tzEmbed = $custom["slide{$i}-embed"]; $page = "<h2>{$tzTitle}</h2><img src='{$tzImage}' />"; $pages[] = $page; $i++; } $numpages = count( $pages ); } }
The topic ‘Have function add variables/values to the $post object?’ is closed to new replies.