• 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 remove Deprecated SymfonyComponentDebugDebugClassLoader?

PHP file_get_contents function

How to add a heading in between checkout fields of WooCommerce

Find out the name of the last script that included the current one

PHP random string generator

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

Cannot pass null argument when using type hinting

WordPress - Dynamically add user ID to the end of a URL

How to get variable from JavaScript to PHP [duplicate]

Merge column values from two arrays to form an indexed array of associative arrays

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

Make certain characters of a word from string bold

Problems getting instance of UploadedFile in Yii2

CSS file not imported in laravel blade view

Call to a member function givePermissionTo() on null

About Contact Privacy policy Terms and conditions