开发者

How to assign a property in php?

开发者 https://www.devze.com 2023-04-08 19:27 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消