Link custom stylesheet to wordpress child theme – anspress
I am using anspress theme. I need to connect a custom CSS file to my website using a child theme. And I need it to only load when on anspress.
Question is closed for new answers.
maxbryan Selected answer as best
- First add this code to function.php
// connect extra css to child theme function for anspress function get_anspress_styles() { Â Â Â Â Â Â Â Â echo "<link rel='stylesheet' href='https://{yourdomain.com}/wp-content/themes/{your_child_theme}/ap_new_styles.css' type='text/css' media='all' . '\n'>"; Â Â Â Â } Â Â Â Â if(class_exists('anspress')){ Â Â Â Â Â Â Â Â echo "<script>console.log('asdasd')</script>"; Â Â Â Â Â Â Â Â add_action( 'wp_enqueue_scripts', 'get_anspress_styles' ); Â Â Â Â } Â Â Â Â // connect extra css to child theme function for anspress
- Second create “ap_new_styles.css” inside wp-content/themes/{your_child_theme}/
- You're done!
maxbryan Selected answer as best