• 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

How to give apache permission to write to home directory?

How to remove from a multidimensional array all duplicate elements including the original?

Return new collection without modifying original collection

Pass a select with mysqli_fetch_row to a table

How to get monthly wise data in laravel

laravel MVC execution flow

Laravel Carbon throws error The format separator does not match

Laravel Database Strict Mode

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

How to validate tin and cst using PHP?

Laravel PackageManifest.php: Undefined index: name

PHP password_verify

Get WooCommerce product variation attribute terms in admin products general box

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Unable to uninstall brew php from homebrew

About Contact Privacy policy Terms and conditions