0

I am applying specific styles in Worpdress when I access a certain URL, for example:

misiito.com/?mobile When I enter there I hide the header and footer. My code is the following:

if ( isset( $_GET['mobile'] ) ) {
    wp_enqueue_style( 'adaptabilidad', plugins_url( 'css/mobile.css', __FILE__ ), array(), '1.0.0' );
}

if ( isset( $_GET['totem'] ) ) {
    wp_enqueue_style( 'adaptabilidad', plugins_url( 'css/totems.css', __FILE__ ), array(), '1.0.0' );
}

My problem is that it doesn't change the links and places the /?mobile, please help me, how can I do it? That is, I want all the buttons at the end to have /?mobile

I tried this, but it's obviously a bug:

add_filter( 'the_content', 'adaptabilidad_nattule_add_mobile_url' );
    function adaptabilidad_nattule_add_mobile_url( $content ) {
        $content = str_replace( 'href="', 'href="?mobile', $content );
        return $content;
    }
principemestizo3
  • 161
  • 3
  • 13

1 Answers1

0

It's just a suggestion, but have you thought of creating duplicate pages (for each styles) with different URL slugs and simply using a plugin like "Simple 301 Redirects" to associate them with a "/something"?

Example: yousite.com/page1-style2 yousite.com/page1-style27

Gary Oak
  • 111
  • 7
  • I understood that you want me to do a 301 redirect, but honestly it was not clear to me. I'll explain, I'm on the link that ends with /?mobile, and if I go to another link like /contact, I want that to end with /?mobile, the same with all links. Because what I am doing is hiding the header and footer from my webview app, if I send the app to a link that does not have the header hidden with ?mobile it would not make sense. – principemestizo3 May 24 '22 at 14:40
  • https://stackoverflow.com/questions/10569768/how-to-make-a-redirect-and-keep-the-query-string – Gary Oak May 24 '22 at 14:42
  • I misunderstood your question – Gary Oak May 24 '22 at 14:43