【问题标题】:Wordpress isn't letting me hide a custom field in a div?Wordpress 不允许我在 div 中隐藏自定义字段?
【发布时间】:2013-06-06 16:26:26
【问题描述】:

此代码必须用于以 wordpress 布局输出我的图像:

<?php 
    $temp_content = explode(" ",substr(strip_tags(get_the_content()),0,175));
    $temp_content[(count($temp_content)-1)] = ''; 
    $new_content = implode(" ",$temp_content);
?>

<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('home-post', 
                         array('alt' => 'post image',
                               'class' => '', 'title' => 
        '<div class="home_post_content">
            <h4>
                <a href="' . get_permalink() . '">
                    ' . get_the_title() . ''. $the_date .'
                </a>
            </h4>'));

我想把the_field('event_date') 放在get_the_title 之后。但是,每当我这样做时,它只会在代码上方或下方输出日期,绝对没有任何格式。

【问题讨论】:

    标签: php css wordpress custom-fields


    【解决方案1】:

    根据您的 css,您会遇到很多问题。请记住,标题是块级元素(它们占据一整行),锚点也可以。我将绘制出我正在尝试创建的 html 并确定需要内联的内容并整理父/子关系。我不确定这是 Wordpress 输出的问题。

    发布正在输出的html和相关的css。

    【讨论】:

      【解决方案2】:

      你应该返回值:

      get_the_field( 'event_date' )

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-02
        • 1970-01-01
        • 2018-08-06
        • 1970-01-01
        相关资源
        最近更新 更多