• 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

args[max_input] woocommerce if statement confused

Ajax GET request fails in laravel 8

PHP: How to raise number to (tiny) fractional exponent?

Spam Filter in Contact Form

How to change product Image when variables are selected in Shop and Archive Pages?

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

CONCAT columns with Laravel 5 eloquent

Add a custom text for a particular product on specific email notification in Woocommerce

CodeIgniter extend CI_URI undefined method

Not able to access model in the controller mautic

How to test laravel controller method?

retrieve data from database using session

Return multiple values from a function using mysqli_fetch_assoc [closed]

PDOException SQLSTATE[HY000] [2002] No such file or directory

Extract house numbers from address string

About Contact Privacy policy Terms and conditions