Я использую Custom Field Plugin Pro. Я создал 3 поля и 4 подполя этого. Теперь, когда я пытаюсь добавить код в одном. php редакторе тем WordPress, он ломает страницу сообщений CSS.
После выяснения вещей я обнаружил, что: при публикации PHP код только 1 поля кода, тогда сайт не ломается. Но ставить 2/3 ломая сайт. Кроме того, я обнаружил, что, когда я вставляю 1-1 запись в каждое поле, веб-сайт прекрасно работает со всеми тремя полями кода. Я не знаю, почему это происходит.
Это код, который я использую в одиночку. php
<!-- Show Custom Fiels---------------->
<div id="Custom_Fields" class="sbox fixidtab">
<style>
table, th, td {
border: 1px solid white;
border-collapse: collapse;
background:black;
}
th, td {
padding: 5px;
text-align: center;
}
</style>
<?php
// Field 1 -----
if( have_rows('Field1') ):?>
<div class="custom_fields" style="overflow-x:auto;">
<h2><?php _d('Type : Name'); ?></h2>
<table style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Type 1</th>
<th>Type 2</th>
<th>Type 3</th>
<th>Type 4</th>
</tr>
</thead>
<tbody>
<?php while ( have_rows('F1') ) : the_row();
$name_F1 = get_sub_field('name');
$type_F1 = get_sub_field('type');
$link_F1 = get_sub_field('link');
$link_F1_full = "<a href=".$link_F1." target='_blank'>Visit Now</a>";
$language_F1 = get_sub_field('language');
?>
<tr>
<td><?php echo $name_F1; ?></td>
<td><?php echo $type_F1; ?></td>
<td><?php echo $link_F1_full; ?></td>
<td><?php echo $language_F1; ?></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<?php
//endwhile;
else :
// no rows found
endif;
?>
</div>
<?php
// Field 2 -----
if( have_rows('Field 2') ):?>
<div class="custom_fields" style="overflow-x:auto;">
<h2><?php _d('Type : Name'); ?></h2>
<table style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Type 1</th>
<th>Type 2</th>
<th>Type 3</th>
<th>Type 4</th>
</tr>
</thead>
<tbody>
<?php while ( have_rows('F2') ) : the_row();
$name_F2 = get_sub_field('name');
$type_F2 = get_sub_field('type');
$link_F2 = get_sub_field('link');
$link_F2_full = "<a href=".$link_F2." target='_blank'>Visit Now</a>";
$language_F2 = get_sub_field('language');
?>
<tr>
<td><?php echo $name_F2; ?></td>
<td><?php echo $type_F2; ?></td>
<td><?php echo $link_F2_full; ?></td>
<td><?php echo $language_F2; ?></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<?php
//endwhile;
else :
// no rows found
endif;
?>
</div>
<?php
// Field 3 -----
if( have_rows('Field 3') ):?>
<div class="custom_fields" style="overflow-x:auto;">
<h2><?php _d('Type : Name'); ?></h2>
<table style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Type 1</th>
<th>Type 2</th>
<th>Type 3</th>
<th>Type 4</th>
</tr>
</thead>
<tbody>
<?php while ( have_rows('F3') ) : the_row();
$name_F3 = get_sub_field('name');
$type_F3 = get_sub_field('type');
$link_F3 = get_sub_field('link');
$link_F3_full = "<a href=".$link_F3." target='_blank'>Visit Now</a>";
$language_F3 = get_sub_field('language');
?>
<tr>
<td><?php echo $name_F3; ?></td>
<td><?php echo $type_F3; ?></td>
<td><?php echo $link_F3_full; ?></td>
<td><?php echo $language_F3; ?></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<?php
//endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
Если я добавлю только код для поля 1, то с веб-сайтом все в порядке:
<!-- Show Custom Fiels---------------->
<div id="Custom_Fields" class="sbox fixidtab">
<style>
table, th, td {
border: 1px solid white;
border-collapse: collapse;
background:black;
}
th, td {
padding: 5px;
text-align: center;
}
</style>
<?php
// Field 1 -----
if( have_rows('Field1') ):?>
<div class="custom_fields" style="overflow-x:auto;">
<h2><?php _d('Type : Name'); ?></h2>
<table style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Type 1</th>
<th>Type 2</th>
<th>Type 3</th>
<th>Type 4</th>
</tr>
</thead>
<tbody>
<?php while ( have_rows('F1') ) : the_row();
$name_F1 = get_sub_field('name');
$type_F1 = get_sub_field('type');
$link_F1 = get_sub_field('link');
$link_F1_full = "<a href=".$link_F1." target='_blank'>Visit Now</a>";
$language_F1 = get_sub_field('language');
?>
<tr>
<td><?php echo $name_F1; ?></td>
<td><?php echo $type_F1; ?></td>
<td><?php echo $link_F1_full; ?></td>
<td><?php echo $language_F1; ?></td>
</tr>
<?php
endwhile;
?>
</tbody>
</table>
<?php
//endwhile;
else :
// no rows found
endif;
?>
</div>
</div>