0

I've got a wordpress page with tabs on it, and I want to show in one of 'em a query of posts from a category.

I've got an active li like: where the tab info is shown

<li class="tab-pane  active" id="ert_pane1-4">

All I came up with is:

<?php
$tab-id= getElementById("ert_pane1-4");
echo $tab-id;
if($tab-id =='<li class="active">'){
query_posts('cat=1');
} endif;
?>)

I know this will sound rather easy but I'm a newbie on php but up to learn.

1 Answers1

0

There are some problems. First, endif; is not needed:

if($tab-id =='<li class="active">'){
query_posts('cat=1');
}

Also, getElementById is JavaScript not PHP. This wouldn't work anyway since the page hasn't loaded yet while PHP is running.

Anonymous
  • 11,748
  • 6
  • 35
  • 57
  • thank you for your answer, getelementsbyid was a wild guess, can't figure out how to make this work since php will run before the page loads, – user3405764 Mar 11 '14 at 11:31
  • Exactly. That's why you can't do this with PHP. You would need to use JavaScript. – Anonymous Mar 11 '14 at 11:34
  • after searching for some info, like passing javascript variables to php and do requested, i think its a think too big for me, any classic hint? much appreciated! in other case, you can close the thread as no solution wont work in the way the question has been placed thank you all that was my first question, hope to make more interesting ones! – user3405764 Mar 11 '14 at 11:59
  • You could use ajax: http://stackoverflow.com/questions/15461786/pass-javascript-variable-to-php-via-ajax – Anonymous Mar 11 '14 at 12:35
  • What if i just use a variable to store the query and them echo it? just returns array. – user3405764 Mar 11 '14 at 14:34
  • You can't run PHP after the page is loaded. It's a server-side language. – Anonymous Mar 11 '14 at 14:44