无法将PHP代码粘贴到PHP文档的HTML部分?

时间:2016-05-08 18:46:48

标签: php implementation

如何放置此代码:$image_url = get_company_field( 'company_office_photo' ); echo '<img src="' . $image_url '" />';

进入下面的那个。我尝试使用<div>选择器,但没有运气,并且出现语法错误。任何帮助表示赞赏。

<?php
/**
 * The template for displaying job listings (in a loop).
 *
 * @package Listify
 */
?>

<li id="job_listing-<?php the_ID(); ?>" <?php job_listing_class(); ?> <?php echo apply_filters(
'listify_job_listing_data', '', false ); ?>>

	<div class="content-box">

		<a href="<?php the_permalink(); ?>" class="job_listing-clickbox"></a>

		<header <?php echo apply_filters( 'listify_cover', 'job_listing-entry-header listing-cover' ); ?>>
            <?php do_action( 'listify_content_job_listing_header_before' ); ?>

**/* I want to place the code in this line */**

			<div class="job_listing-entry-header-wrapper cover-wrapper">
				
				<div class="job_listing-entry-thumbnail">
					<div <?php echo apply_filters( 'listify_cover', 'list-cover' ); ?>></div>
				</div>
				
				<div class="job_listing-entry-meta">
					<?php do_action( 'listify_content_job_listing_meta' ); ?>
				</div>

			</div>

            <?php do_action( 'listify_content_job_listing_header_after' ); ?>
		</header><!-- .entry-header -->

		<footer class="job_listing-entry-footer">

			<?php do_action( 'listify_content_job_listing_footer' ); ?>

		</footer><!-- .entry-footer -->

	</div>
</li><!-- #post-## -->

1 个答案:

答案 0 :(得分:1)

这应该有效:     

<li id="job_listing-<?php the_ID(); ?>" <?php job_listing_class(); ?> <?php  echo apply_filters(
'listify_job_listing_data', '', false ); ?>>

<div class="content-box">

    <a href="<?php the_permalink(); ?>" class="job_listing-clickbox"></a>

    <header <?php echo apply_filters( 'listify_cover', 'job_listing-entry-header listing-cover' ); ?>>
        <?php do_action( 'listify_content_job_listing_header_before' ); ?>

         <?php $image_url = get_company_field( 'company_office_photo' ); ?>
             <img src="<?php echo $image_url ?>" />

        <div class="job_listing-entry-header-wrapper cover-wrapper">

            <div class="job_listing-entry-thumbnail">
                <div <?php echo apply_filters( 'listify_cover', 'list-cover' ); ?>></div>
            </div>

            <div class="job_listing-entry-meta">
                <?php do_action( 'listify_content_job_listing_meta' ); ?>
            </div>

        </div>

        <?php do_action( 'listify_content_job_listing_header_after' ); ?>
    </header><!-- .entry-header -->

    <footer class="job_listing-entry-footer">

        <?php do_action( 'listify_content_job_listing_footer' ); ?>

    </footer><!-- .entry-footer -->

</div>