• 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

enable Apache http Authorization header

Getting output of MS stored procedure on php call

Laravel relationship belongsToMany with composite primary keys

Session timeout in Yii2

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Woocommerce Checkout - Add conditional field required if one field is filled

PHP returning an error message and false

How to downgrade or install a specific version of Composer?

How avoid Moved Permanently The document has moved here

Get orders by date and status woocommerce

Mobile browsers are adding .html to filename on download

Return multiple values from a function using mysqli_fetch_assoc [closed]

Required field only if another field has a value, must be empty otherwise

how to insert data into select2 search input after scan using qrcode

Apply session id from request header

About Contact Privacy policy Terms and conditions