Doing an if statement with wordpress <?php the_permalink(); ?> -


i want make condition when template loads, if perma link /xxxx/butiker this...

and if /xxxx/services loop this.

or if /xxxx/cafeer loop this.

if render out <?php the_permalink(); ?> full link, need code check .com/xxx/this part. assist?

split url using phps explode() function:

$link = get_permalink(); $temp = explode("/",$link); print_r($temp); 

the get_permalink() function returns url, , print_r prints array. part want check in if condition like;

for example:

array ( [0] => www.xyz.com         [1] => xxx         [2] => services       )  

if($temp[2] == "services"){      //your loop services ,cafeer etc.. } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -