• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

advanced custom fields wordpress custom class

phpwordpressadvanced-custom-fields


PHP Snippet 1:

/* Target Page 1 Button */
.page-1 .btn {
  background-color: red;
}
/* Target Page 2 Button */
.page-2 .btn {
  background-color: blue;
}

PHP Snippet 2:

<?php
// e.g. in functions.php
function extraButtonClass() {
  // Target by page slug or ID
  if(is_page('page-1')) {
    return ' red';
  } elseif(is_page('page-2')) {
    return ' blue';
  } else {
    return null;
  }
}

// In template:
<button class="btn<?php echo extraButtonClass(); ?>">My Button</button>

Related Snippets

Cannot pass null argument when using type hinting

Hide specific products from unlogged users based in product category in WooCommerce

How to modify CSS in a specific page of the WP admin dashboard (backend)

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

SilverStripe unable to populate multiple member Childs

CSV to PHP class properties

Laravel Livewire: jQuery not working in child component loaded via @if statement

Laravel: Create morphs() relationship nullable

Problem with fetching data from database in Laravel

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

Reducing authentication calls on external API (Laravel 5.6)

Best way to scrolldown onpageload

Set quantity minimum, maximum and step at product level in Woocommerce

Explode not working properly with dash

Put content of wordpress page inside div

About Contact Privacy policy Terms and conditions