madest
Новичок
Ребята, мучаюсь четвертые сутки с кодом. Буду очень благодарен если поможете. Короче, вот функция которая вставляется в функшн.пшп (вордпресс).
Она умножает курс (get_current_rate), на цифру произвольного поля страницы и в итоге на странице получается готовая цена. А теперь я хочу вывести эту же цену на родительскую страницу, в плагин. И у меня ничего не получается. Посмотрите пожалуйста. Может кто нибудь разберётся...
В плагине вот что, вставляю кусочек кода плагина, который, на мой взгляд, нужен:
"ЧТО ТУТ ВСТАВИТЬ ТОЖЕ НЕ ЗНАЮ" : там нужно вывести, в этом месте.
PHP:
function get_current_rate(){
return 13000;
}
function get_post_price_in_byr($post_id = false){
global $post, $id;
$post_id = (int)$post_id;
$price = 0;
if (!$post_id) $post_id = $id;
$cena_values = get_post_custom_values( 'cena',$post_id );
if (!empty($cena_values)){
foreach($cena_values as $key => $value ) {
$price = $value * get_current_rate();
}
}
return $price;
}
function get_nice_price($price){
if (!empty($price) && $price>0)
return number_format($price,0,',',' ')." бел. руб.";
else
return '';
}
В плагине вот что, вставляю кусочек кода плагина, который, на мой взгляд, нужен:
PHP:
if ( $show_title == 1 ) {
$list_pages_html .= '<h3 class="page-list-ext-title"><a href="'.$link.'" title="'.esc_attr($page->post_title).'">'.$page->post_title.'</a></h3>';
}
if ( $show_content == 1 ) {
//$content = apply_filters('the_content', $page->post_content);
//$content = str_replace(']]>', ']]>', $content); // both used in default the_content() function
if ( !empty( $page->post_excerpt ) ) {
$text_content = $page->post_excerpt;
} else {
$text_content = $page->post_content;
}
if ( post_password_required($page) ) {
$content = '<!— password protected —>';
} else {
$content = pagelist_unqprfx_parse_content( $text_content, $limit_content, $strip_tags, $strip_shortcodes, $more_tag );
$content = do_shortcode( $content );
if ( $show_title == 0 ) { // make content as a link if there is no title
$content = '<a href="'.$link.'">'.$content.'</a>';
}
}
$list_pages_html .= '<div class="page-list-ext-item-content">
<p>Цена:'.ЧТО ТУТ ВСТАВИТЬ ТОЖЕ НЕ ЗНАЮ.' бел. руб. </p>
<p><a href="'.$link.'" title="'.esc_attr($page->post_title).'">подробнее</a></p></div>';
Последнее редактирование: