Custom post type with Blade

I want to add the following script from ‘add to any plugin’ to work only on ‘Single Posts’. How do I restrict it only on posts.
“function”==typeof jQuery&&jQuery(document).ready(function(a){a(“body”).on(“post-load”,function(){window.a2a&&a2a.init_all()})});

Not sure if you found a solution to this problem already, but here goes…

One way to do it is this:

In resources/assets/scripts/routes/ folder add a JS file and call it singlePost.js.

Copy the code below and paste the code you want to use in the finalize() function:

export default {
  init() {
    // JavaScript to be fired on the home page
  },
  finalize() {
    // PASTE YOUR CODE HERE
  },
};

In main.js add:

import singlePost from './routes/singlePost';

Then add it to the Router:

const routes = new Router({
  // All pages
  common,
  // Home page
  home,
  // About Us page, note the change from about-us to aboutUs.
  aboutUs,
  // Fire on Single Posts only
  singlePost,
});

This topic was automatically closed after 42 days. New replies are no longer allowed.