taxonomy - Adding Advanced Custom Fields to posts without hyperlinks

I'm trying to display custom fields on my post like this:<ul><li><?php the_field('name_of_place

I'm trying to display custom fields on my post like this:

<ul>
                    <li><?php the_field('name_of_placement'); ?></li>
                    <?php
                            $terms = get_the_terms( get_the_ID(), 'country' );
                            $names = array();

                            foreach ( $terms as $term ) {
                                $names[] = $term->name;
                            }

                            echo '<li>' . implode( ', ', $names ) . '<li>';
                    ?>
                    <?php
                            $terms = get_the_terms( get_the_ID(), 'timeframe' );
                            $names = array();

                            foreach ( $terms as $term ) {
                                $names[] = $term->name;
                            }

                            echo '<li>' . implode( ', ', $names ) . '<li>';
                    ?>
                    <li><?php the_terms( get_the_ID(), 'types_of_healthcare_placement' ); ?></li>

                </ul>

The problem is like this form creates an extra blank <li> item after each field.

/

How can i fix it?

I'm trying to display custom fields on my post like this:

<ul>
                    <li><?php the_field('name_of_placement'); ?></li>
                    <?php
                            $terms = get_the_terms( get_the_ID(), 'country' );
                            $names = array();

                            foreach ( $terms as $term ) {
                                $names[] = $term->name;
                            }

                            echo '<li>' . implode( ', ', $names ) . '<li>';
                    ?>
                    <?php
                            $terms = get_the_terms( get_the_ID(), 'timeframe' );
                            $names = array();

                            foreach ( $terms as $term ) {
                                $names[] = $term->name;
                            }

                            echo '<li>' . implode( ', ', $names ) . '<li>';
                    ?>
                    <li><?php the_terms( get_the_ID(), 'types_of_healthcare_placement' ); ?></li>

                </ul>

The problem is like this form creates an extra blank <li> item after each field.

http://electives-abroad/custom-field-test/

How can i fix it?

Share Improve this question edited Apr 29, 2019 at 13:08 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 29, 2019 at 12:33 Draws Ren GundamDraws Ren Gundam 251 gold badge2 silver badges6 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

The code seems to be good to me, may be try to correct this line :

echo '<li>' . implode( ', ', $names ) . '<li>';

To :

echo '<li>' . implode( ', ', $names ) . '</li>';

You forget to close the li tag.

Same thing here :

echo '<li>' . implode( ', ', $names ) . '</li>';

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745541751a4632158.html

相关推荐

  • taxonomy - Adding Advanced Custom Fields to posts without hyperlinks

    I'm trying to display custom fields on my post like this:<ul><li><?php the_field('name_of_place

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信