在Wordpress 6.0中新增区块主题(完整的网站编辑主题)没有PHP页面,只有html模板和模板部分。我安装了“Astory”-完整的网站编辑主题。我添加了我的外部PHP页面作为自定义模板添加到WordPress页面。但无法获得其他页眉,页脚,侧边栏块和样式。如何包括自定义PHP代码页与主题模板样式在新的完整的网站编辑主题?
<?php
/**
- @包一个故事-孩子 */
/* 模板名称:会员注册页面 */
?〉
<?php
get_header();
?>
</main>
<div class="pageheading"><h1><?php the_title(); ?></h1></div>
<?php the_content();
全局$wpdb;
//$memberhousedet = $wpdb->get_results("SELECT * FROM wp_fluentform_entry_details WHERE field_name in ('house_no','house_name','house_ownr') GROUP BY id HAVING count(field_name)=1 ORDER BY submission_id"); -> TRASHED VALUES AVOIDED
$memberhousedet = $wpdb->get_results("SELECT * FROM wp_fluentform_entry_details WHERE field_name in ('house_no','house_name','house_ownr') and submission_id NOT IN (SELECT id FROM `wp_fluentform_submissions` where status='trashed' and form_id=6) GROUP BY id HAVING count(field_name)=1 ORDER BY submission_id");
foreach($memberhousedet as $housedet){
//echo '<br/>';
$hstblsbvlidary[]= $housedet -> submission_id;
$housetblid= $housedet -> id;
$housedetsbmsnval= $housedet -> submission_id;
$housedetres= $housedet -> field_name;
$housedetval= $housedet -> field_value ;
$housedetvals[] = array($housetblid,$housedetsbmsnval,$housedetres, $housedetval);
//$housedetvals[]= array('id'=>$housetblid,'sbval'=>$housedetsbmsnval,'fieldname'=>$housedetres,'value'=>$housedetval);
//echo '<br/>';
}
$distnctsbvals=array_unique($hstblsbvlidary);
//print_r($housedetvals);
$cntoftothusdet=count($housedetvals);
$cntofdstnctentry=count($distnctsbvals);
$rstarykeyvals=array_values($distnctsbvals);
//print_r($rstarykeyvals);
for($i=0;$i<$cntofdstnctentry;$i++){
// $rstarykeyvals[$i];
$cnt=0;
while($cnt<$cntoftothusdet){
if($rstarykeyvals[$i]==$housedetvals[$cnt][1]){
//echo '<br/>';
//echo $housedetvals[$cnt][1].' , '.$housedetvals[$cnt][2].' , '.$housedetvals[$cnt][3];
$hsdetcmbndary[$housedetvals[$cnt][1]][$housedetvals[$cnt][2]]=$housedetvals[$cnt][3];
}
$cnt++;
}
//
}
// print_r($rstarykeyvals);
//$hsdetcmbndary[204]['house_no']['house_name'];
// echo $hsdetcmbndary[204]['house_no'].' - '.$hsdetcmbndary[204]['house_name'];
$ic=0;
while($ic<$cntofdstnctentry){
$housnonnamepasngary[] = $hsdetcmbndary[$rstarykeyvals[$ic]]['house_no'].' - '.$hsdetcmbndary[$rstarykeyvals[$ic]]['house_name'];
if (isset($hsdetcmbndary[$rstarykeyvals[$ic]]['house_ownr'])){
$housownernmpsngary[$hsdetcmbndary[$rstarykeyvals[$ic]]['house_no'].' - '.$hsdetcmbndary[$rstarykeyvals[$ic]]['house_name']]=$hsdetcmbndary[$rstarykeyvals[$ic]]['house_ownr'];
}else{
$housownernmpsngary[$hsdetcmbndary[$rstarykeyvals[$ic]]['house_no'].' - '.$hsdetcmbndary[$rstarykeyvals[$ic]]['house_name']]='-';
}
$ic++;
}
//print_r($housownernmpsngary);print_r($housnonnamepasngary); // -> This array has to be passed to jQ for populate in dropdown
$encodedpasableary = json_encode($housnonnamepasngary);
$hsownrjsnary = json_encode($housownernmpsngary);
// echo $hsownrjsnary;
echo '<div class="wp-block-columns">';
//$unq_mem_id=$_POST['unq_id']; $mem_id=$_POST['mem_id'];
echo do_shortcode( '[fluentform id="7"]' );
echo '</div>';
?>
<script>
jQuery(document).ready(function($){
var jsonhsvals = <?php echo $encodedpasableary; ?>;
var jsnhsownrvals = <?php echo $hsownrjsnary; ?>;
//var housdetvals = $.parseJSON(jsonhsvals.value);
//JSON.stringify(myobject);
console.log(jsonhsvals);
$cntofhousdetary=jsonhsvals.length;
for(i=0; i<$cntofhousdetary; i++) {
$('#ff_7_house_name_select').append("<option value='"+jsonhsvals[i]+"'>"+jsonhsvals[i]+"</option>");
}
//alert(jsonhsvals.length);
$("#ff_7_housownr").prop('readonly', true);
//var conceptName = $('#aioConceptName :selected').text();
$('#ff_7_house_name_select').change(function(){
//alert('dropdown value changed !!!'); alert($(this).val());
var slctd_housenonam=$(this).val();
$("#ff_7_housownr").val(jsnhsownrvals[slctd_housenonam]);
});
});
</script>
This is a fluent form registration table with dynamic popup and selection added by php and jquery. I want to add this php page into my wordpress theme with same theme styles.
在旧的主题中我可以通过从page.php中复制div类来添加,但是在新的块主题中没有page.php页面。所以我不能添加相同的主题样式。
1条答案
按热度按时间lstz6jyr1#
找到了一个有用的网站,关于在wordpress块主题中添加php模板的所有信息。
这里的链接:
https://fullsiteediting.com/lessons/how-to-use-php-templates-in-block-themes/