WordPress.org

Ready to get started?Download WordPress

Forums

best theming way (4 posts)

  1. cristopher_elsner
    Member
    Posted 2 years ago #

    hi,

    I want different sidebar(right). For now I am using this way:

    <?php
    if($url_check=='contact')
    {
    CONTACT FORM
    }
    else if($url_check=='about_us')
    {
    TESTIMONIALS
    }
    ?>

    This way Conditions I am using are STATIC like contact,about_us.
    Now what If admin changes contact to contact-us.

    So, I want Dynamic Solution(condition).

    Please help me...

    Thanks
    Cristopher.

  2. mr49online
    Member
    Posted 2 years ago #

    Hi, cristopher_elsner!!!
    Try this scenario, get the permalink and try to explode it, and pass its last array index which is your page name.

    Example:

    <?php
      $permalink = get_permalink( );
          $c = explode('/', $permalink);
    	echo "<pre>";
    	  print_r($c);
    	echo "</pre>";
    	$a = $c[4];
    	echo $a;
    ?>

    OutPut:

    http://localhost/wp-quickstart/testpage
    Array
    (
        [0] => http:
        [1] =>
        [2] => localhost
        [3] => wp-quickstart
        [4] => testpage
    )
    testpage
  3. cristopher_elsner
    Member
    Posted 2 years ago #

    hi mr49online,

    Thank you for your help.

  4. mr49online
    Member
    Posted 2 years ago #

    @cristopher_elsner: you welcome .......... :),
    hope you got the solution of your issue, isn't it?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags