Okay
  Public Ticket #2346048
Ajax and page id
Closed

Comments

  •  2
    romain started the conversation

    Hello again,

    With ajax loading, the page is not really changing.
    So the class ".page-id-xx" (in <body> tag) doesn't change either.

    However, it is the simplest and unique identifier for applying CSS for a specific page.

    Here we can't, and it's a problem.

    Could you write dynamically the good unique class in the body tag ?

    • page-id-xx for pages
    • postid-xxx for posts (or portfolio)

    Thanks !

  •  1,974
    Support replied

    Hi Romain

    Ajax page transitions will load the target page content container within the original page. Since the target page is not loaded normally the <head> and <body> elements will stay the same.

    so the target page container is  div cd-main-content and if you open /js/scripts.js you will see the code that loads the page:

    l.load(t + " .cd-main-content > *", function(e) {

    in function AjaxLoad() that is minimized for good reason.

    so basically yo should load the entire page, get what classes you need from the target body , load it in the current body and so on. 


    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  •  2
    romain replied

    I understand the process. But I dont know how to inject the unique id from loaded page in this tag.

    If it's not too complex, could you insert it like that in a future update ?

    <div class="cd-index cd-main-content page-id-xx">

    Many thanks !

  •  1,974
    Support replied

    That's the problem we are facing too it's pretty difficult. We will be looking into it though. 

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  •  2
    romain replied

    Ok, thanks for that !

  •  1,974
    Support replied

    Romain try this plz

    In header.php replace line 30 with

    <div class="cd-index cd-main-content post_id_<?php echo sanitize_html_class( get_the_ID() ); ?>">

    And let us know if it works for you

    Thank you.

    Clapat Support

    https://www.clapat.com/

    Review Envato Item Support Policy

  •  2
    romain replied

    Thanks for this.

    I tried, but the post_id_xx is displayed only at first click. If another page is loaded, or portfolio single, the div becomes <div class="cd-main-content"> .