cp_street, cp_city, cp_mobile_no, cp_company_name
그리고 훨씬 더 같은 일부 사용자 정의 필드를 만드는 오전. 어느 페이지 single_ad_listing.php 에 표시되며, 코드
cp_get_ad_details($post->ID, $cat_id);
과 테마 function.php 페이지 코드는
// display all the custom fields on the single ad page, by default they are placed in the list area
if (! function_exists('cp_get_ad_details')) {
function cp_get_ad_details($post_id, $category_id, $location = 'list') {
global $wpdb;
// see if there's a custom form first based on category id.
$form_id = cp_get_form_id($category_id);
$post = get_post($post_id);
if (! $post)
return;
// if there's no form id it must mean the default form is being used
if (! $form_id) {
// get all the custom field labels so we can match the field_name up against the post_meta keys
$sql = "SELECT field_label, field_name, field_type FROM $wpdb->cp_ad_fields";
} else {
// now we should have the formid so show the form layout based on the category selected
$sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, m.field_pos FROM $wpdb->cp_ad_fields f "
. "INNER JOIN $wpdb->cp_ad_meta m ON f.field_id = m.field_id WHERE m.form_id = %s ORDER BY m.field_pos ASC", $form_id);
}
$results = $wpdb->get_results($sql);
if (! $results) {
_e('No ad details found.', APP_TD);
return;
}
// allows to hook before ad details
cp_action_before_ad_details($results, $post, $location);
foreach ($results as $result) {
// external plugins can modify or disable field
$result = apply_filters('cp_ad_details_field', $result, $post, $location);
if (! $result)
continue;
$disallow_fields = array('cp_price', 'cp_currency');
if (in_array($result->field_name, $disallow_fields))
continue;
$post_meta_val = get_post_meta($post->ID, $result->field_name, true);
if (empty($post_meta_val))
continue;
if ($location == 'list') {
if ($result->field_type == 'text area')
continue;
if ($result->field_type == 'checkbox') {
$post_meta_val = get_post_meta($post->ID, $result->field_name, false);
$post_meta_val = implode(", ", $post_meta_val);
}
$args = array('value' => $post_meta_val, 'label' => $result->field_label, 'id' => $result->field_name, 'class' => '');
$args = apply_filters('cp_ad_details_' . $result->field_name, $args, $result, $post, $location);
if ($args)
echo '<li id="' . $args['id'] . '" class="' . $args['class'] . '"><span>' . esc_html(translate($args['label'], APP_TD)) . ':</span> ' . appthemes_make_clickable($args['value']) . '</li>';
} elseif ($location == 'content') {
if ($result->field_type != 'text area')
continue;
$args = array('value' => $post_meta_val, 'label' => $result->field_label, 'id' => $result->field_name, 'class' => 'custom-text-area dotted');
$args = apply_filters('cp_ad_details_' . $result->field_name, $args, $result, $post, $location);
if ($args)
echo '<div id="' . $args['id'] . '" class="' . $args['class'] . '"><h3>' . esc_html(translate($args['label'], APP_TD)) . '</h3> ' . appthemes_make_clickable($args['value']) . '</div>';
}
}
모든 항목이 순차적으로 표시하지만 주소를 cp_street, cp_city
상단을 좋아 할 것입니다 페이지 및 모바일 번호 (cp_mobile_no) 페이지의 오른쪽과 나머지 필드는 같은 위치를 표시합니다.
제발 도와주세요 ... 우리가 고급 사용자 정의 필드 플러그인 전문 홈 페이지를 만드는 데 사용할 수있는 방법을 살펴 것이 튜토리얼에서는
이제 페이지의 그래픽보기를 만들고 싶습니까? CSS를 사용하여 스타일을 제공하는 html 페이지에서 PHP 코드를 구현해야합니다. 원하는 작업은 무엇입니까? – Mitro
나는 연속적으로 표시되는이 사용자 정의 필드를 배열 중입니다. 주소 (거리, 도시, 주, 국가)가 페이지 상단에 표시되고 모바일 번호가 필요합니다. 페이지의 오른쪽 표시와 나머지 필드는 같은 위치를 표시합니다. 이 코드 작성을 도와주세요. – Sanjib
재방송을 위해 Alessio를 주셔서 감사합니다. 내 웹 사이트 (http://www.opendeals.in/ads/online-jobs-in-india-without-any-investment/)를 보시고 내 문제를 이해하십시오. – Sanjib