My Blog
WordPress PHP συνάρτηση: Προσθήκη CSS με βάση το url
Αν θέλετε να προσθέσετε CSS σε συγκριμένη σελίδα ή κατηγορία-taxonomy κλπ, ορίστε ένας γρήγορος τρόπος:
// Function to apply css on specific page url by NicolasLagios.com
add_action( 'init', 'css_me_bash_to_url_by_Nicolas' );
function css_me_bash_to_url_by_Nicolas() {
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if ( false !== strpos( $url, 'string' ) ) { //edw allazoume to string opws epithimoume, px gia to sitemoy.com/site/kati/katiallo.html , tha baloume "kati"
echo '<style type="text/css">
/* edw grafoume to css */
</style>';
}
}
- Αλλάζουμε το string
- Γράφουμε το css
- Βάζουμε το function στο child theme ή στο my custom functions plugin
Αν χρειαστείτε βοήθεια
This post is also available in:
English
