How do I convert links from




This code

    $post_id = $_GET["go"];
    <ul class="subNav">
    <li class="<?php echo $post_id == '' ? 'selected' : ''; ?>"><a href="<?php the_permalink() ?>">info</a></li>
    <li class="<?php echo $post_id == 'seasons' ? 'selected' : ''; ?>"><a href="<?php the_permalink() ?>?go=seasons">seasons</a></li>
    <li class="<?php echo $post_id == 'characters' ? 'selected' : ''; ?>"><a href="<?php the_permalink() ?>?go=characters">characters</a></li>
    if($post_id == 'seasons'):
        $setion = get_template_part('inc/parts/single/seasons');
    elseif($post_id == 'characters'):
        $setion = get_template_part('inc/parts/single/characters');
        $setion = get_template_part('inc/parts/single/info');

Any help, please?
I am tired of the experiences ^^

  • What is "go"? Is that a taxonomy (like a category or tag)? If so, have you registered that as a taxonomy? – JakeParis Feb 10 at 1:30
  • Not category or tag ... just a regular name that I chose to go to the target content for clarity – davnshi Feb 10 at 10:32

Probably the easiest way to solve this would be to add classes to your body tag based on the value of the parameter. You would just want to be sure to sanitize it. You can add classes to the body using the body_class filter which feeds in all the current classes as an array.

You might try something like the following at the top of your template file:

add_filter('body_class', function($classes) {
  if( ! isset($_GET['view']) )
    return $classes;
  $classes[] = "post-layout-" . esc_attr($_GET['view']);

  return $classes;

Now based on the body having a class of post-layout-list or post-layout-grid, you could style your posts list differently.

This has the advantage of less php logic to juggle. Note that this answer is meant to help think through the strategy, rather than as code that you can just copy and paste.

  • Can you apply it to my code I did not understand exactly what you mean. – davnshi Feb 9 at 20:04
  • I have modified the code that I am working on – davnshi Feb 9 at 21:06
  • Can you amend my code, please – davnshi Feb 10 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.