[英]How to store data.id to php variable
请查看代码,它是一个wordpress主题模板。 在获取帖子ID时遇到问题,该问题存储在data.id中。 当我们编写{{data.id}}
时会显示它。
我需要在php变量中获取此值。
我试过了:
$id = $data->id;
$id = $data['id'];
但是这些不起作用。
我需要一些东西: $id = {{data.id}};
这是原始代码,其中第一行包含{{data.id}}
<li id="listing-{{data.id}}" class="job_listing type-job_listing card-style--default style-grid {{data.styles.cardClasses}}">
<script id="tmpl-listingCard" type="text/template">
<?php
/**
* Insert content before a listing.
*
* @since 2.0.0
*/
do_action( 'listify_listing_card_before' );
?>
<li id="listing-{{data.id}}" class="job_listing type-job_listing card-style--default style-grid {{data.styles.cardClasses}}">
<div class="content-box">
<?php
/**
* Insert content at the start of the listing.
*
* @since Unknown
*
* @hooked Listify_Astoundify_Favorites::render_js() - 10
*/
do_action( 'listify_content_job_listing_before' );
?>
<a href="{{data.permalink}}" class="job_listing-clickbox"<# if ( data.cardDisplay.target) { #> target="_blank"<# } #>></a>
<header class="job_listing-entry-header listing-cover <# if ( data.featuredImage.url ) { #>has-image<# } #>" <# if ( data.featuredImage.url ) { #>style="background-image:url({{data.featuredImage.url}})"<# } #>>
<?php
/**
* Insert content before the listing header.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_header_before' );
?>
<div class="job_listing-entry-header-wrapper cover-wrapper">
<?php
/**
* Insert content at the start of the listing header.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_header_start' );
?>
<div class="job_listing-entry-meta">
<# if ( data.status.featured && 'badge' === data.styles.featuredStyle ) { #>
<div class="listing-featured-badge">{{data.i18n.featured}}</div>
<# } #>
<# if ( data.cardDisplay.title ) { #>
<h3 class="job_listing-title">{{{data.title}}}</h3>
<# } #>
<# if ( data.cardDisplay.address && data.location ) { #>
<div class="job_listing-location">{{{data.location.address}}}</div>
<# } #>
<# if ( data.cardDisplay.telephone && data.telephone ) { #>
<div class="job_listing-phone">{{data.telephone}}</div>
<# } #>
<?php
/**
* Insert content after other meta information.
*
* @since unknown
*/
do_action( 'listify_content_job_listing_meta' );
?>
</div>
<?php
/**
* Insert content at the end of the listing header.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_header_end' );
?>
</div>
<?php
/**
* Insert content after the listing header.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_header_after' );
?>
</header>
<# if ( data.cardDisplay.rating || data.cardDisplay.secondaryImage || data.cardDisplay.claimed ) { #>
<footer class="job_listing-entry-footer">
<?php
/**
* Insert content at the start of the listing footer.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_footer' );
?>
<# if ( data.cardDisplay.rating ) { #>
<div class="listing-stars">
<# if ( data.reviews ) { #>
<# for ( var i = 1; i <= data.reviews.stars.full; i++ ) { #>
<span class="listing-star listing-star--full"></span>
<# } for ( var i = 1; i <= data.reviews.stars.half; i++ ) { #>
<span class="listing-star listing-star--half"></span>
<# } for ( var i = 1; i <= data.reviews.stars.empty; i++ ) { #>
<span class="listing-star listing-star--empty"></span>
<# } #>
<# } #>
</div>
<div class="heading_footer">
</div>
<# } #>
<# if ( data.cardDisplay.secondaryImage && data.secondaryImage.url ) { #>
<div class="listing-entry-company-image listing-entry-company-image--card listing-entry-company-image--type-{{data.secondaryImage.type}} listing-entry-company-image--style-{{data.secondaryImage.style}}">
<# if ( data.secondaryImage.permalink ) { #><a href="{{data.secondaryImage.permalink}}"><# } #>
<img class="listing-entry-company-image__img listing-entry-company-image__img--type-logo listing-entry-company-image__img--style-{{data.secondaryImage.style}}" src="{{{data.secondaryImage.url}}}" alt="{{data.title}}" />
<# if ( data.secondaryImage.permalink ) { #></a><# } #>
</div>
<# } #>
<# if ( data.cardDisplay.claimed && data.status.claimed ) { #>
<span class="claimed-ribbon">
<span class="ion-checkmark-circled"></span>
</span>
<# } #>
</footer>
<# } #>
<?php
/**
* Insert content at the end of the listing.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_after' );
?>
</div>
</li>
<?php
/**
* Insert content after a listing.
*
* @since 2.0.0
*/
do_action( 'listify_listing_card_after' );
?>
</script>
这是一个javascript变量,它是从php端分配的,您可以从php代码中获取它,您应该找到javascript在哪里获取此变量数据,然后可以找到所需的变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.