How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?

I dont know how I missed out on that while looking for aproaches, but I have a working solution now based on this answer. I modified it to check for slashes in $query->request, if there is none I first look for my custom post type (get_posts() with’slug’ => $query->request). If no post is found I … Read more

Passing queries in the Homepage loads index.php instead of front-page.php

There are some fundamental misunderstandings happening here, but importantly: The variables on the main query are what are used to decide which conditionals are true. E.g. will is_home return true, is is_search true? It does this by inspecting the query variables. It’s these conditionals and variables that are then used to decide which template should … Read more

`query_var` values empty in theme file after `add_rewrite_rule` redirection

Changing the add_rewrite_rule did the trick: add_rewrite_rule(‘^periodicals/([^/]+)-‘.$tlv[‘code’].'[/]?$’, ‘index.php?periodicals=$matches[1]&post_type=periodicals&name=$matches[1]&mlang=’.$tlv[‘code’], ‘top’); So, I assume for custom post types, using add_rewrite_rule with index.php as query need some extra query variables. A sample will be as: add_rewrite_rule(‘^<custom_post_type>/([^/]+)-‘.$tlv[‘code’].'[/]?$’, ‘index.php?<custom_post_type>=$matches[1]&post_type=<custom_post_type>&name=$matches[1]&mlang=’.$tlv[‘code’], ‘top’);

Why does $_GET return values but get_query_var does not?

Because they do different things and source their data from different places. $_GET is for URL parameters, values passed via HTTP GET. get_query_var is for fetching the query variables of the main post query aka the WP_Query object. Query variables and GET values are not the same thing. Query variables usually get their values either … Read more

techhipbettruvabetnorabahisbahis forumuedusedueduedusedusedusedueduedusedus