Passing url value to block filter

Posted in: Newspaper
Post count: 5

I am passing a value/variable through the page url to a Newspaper page. I have a Visual Composer Block Element (11) on that page and would like to pass that variable to the “Filter by tag slug”. Can and how do I do that?

Post count: 6535

Hi

Basically you will need a function which pass the value from url as a tag in block’s shortcode. Here is an example code which insert a custom value in shortcode:

$v = $_GET['val'];
$block = '';
if (isset($v)){
$block .= do_shortcode('[vc_row][vc_column][td_block_11 tag_slug="' . $v . '" limit="3"][/vc_column][/vc_row]');
}

This code can be used as a function in fuctions.php then you can try to generate a new shortcode for that block using add_shortcode() function. For more details about add_shortcode function check this link: https://codex.wordpress.org/Function_Reference/add_shortcode After you generate the shortcode can be used in visual composer. This link may also help: https://codex.wordpress.org/it:Riferimento_funzioni/do_shortcode

Note that you will need some codeing skills in order to complete this task. I’ve offered just a basic example above but if you still need guidance on this or you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer customization services at the moment.

Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.