如何使用Wordpress自定义字段指定内容对齐方式?
我在标题中有:
$pagealign = get_post_meta($id, 'pagealign', false);
if (!empty($pagealign) && is_single())
{
if ($pagealign=="center")
{
//how to specify css for #pagecontent within php
}
}
发布于 2012-01-28 16:47:19
我建议将结果设置为变量share g+ share fb share tw
如何使用Wordpress自定义字段指定内容对齐方式?
我在标题中有:
$pagealign = get_post_meta($id, 'pagealign', false);
if (!empty($pagealign) && is_single())
{
if ($pagealign=="center")
{
$align = $pagealign
}
}
然后,根据您所说的align的确切含义,您可以使用该变量通过内联css来定义它……
所以我只是在猜测文本对齐
<div id='somediv' style='text-align:<?php echo $pagealign?>;'></div>
发布于 2012-01-29 03:22:27
我知道问题所在: get_post_meta应该以TRUE而不是FALSE结尾
$pagealign = get_post_meta($id, 'pagealign', true);
if (!empty($pagealign) && is_single())
{
if ($pagealign=="center") echo '<style type="text/css">#page-wrap {left:0px;margin-left:auto;margin-right:auto;position:relative;}</style>' ;
if ($pagealign=="right") echo '<style type="text/css">#page-wrap {left:auto;right:30px;}</style>' ;
}
https://stackoverflow.com/questions/9046642
复制相似问题