How to assign a property in php?
I have given an <a>
element a data-filter
property, as shown:
<ul>
<li>
<a href="#" data-filter="*" class="all current"><?php _e('All', 'framework'); ?></a>
<span>/</span>
</li>
<?php
wp_list_categories(array(
'title_li' => '',
'taxonomy' =>开发者_如何学Go;
'skill-type',
'walker' => new Portfolio_Walker(),
'show_option_none' => ''
)
);
?>
</ul>
How can I pass this data-filter
property to PHP?
How can I pass this data-filter property to PHP?
You can't. It's not possible using pure HTML and PHP to transfer a certain (made-up) HTML attribute to PHP. A decent alternative is to use a form instead, where you could select a radio button and submit the form.
EDIT:
Another alternative is to simply pass the filter through the request's query string:
<li>
<a href="?data-filter=*" class="all current"><?php _e('All', 'framework'); ?></a>
<span>/</span>
</li>
// in PHP:
$data_filter = $_GET['data-filter'];
echo $data_filter;
精彩评论