• 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

Telegram bot doesn't answer

Losing session data after POST from third party website

Show rotation of tweets using current day of month

how to upload binary image to sql server using php laravel

Display specific shipping method if woocommerce product has specific acf field value

Composer Script echo

How to break out of a foreach once a condition is met?

Performance of foreach, array_map with lambda and array_map with static function

Cannot pass null argument when using type hinting

The sum of the user's points

Change user role if checkout custom checkbox is checked in WooCommerce

Popup Window and PHP form

Laravel Mix Uncaught ReferenceError: $ is not defined

Transpose csv file data [duplicate]

How to show selected value using javascript in laravel

About Contact Privacy policy Terms and conditions