• 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

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Adding reCAPTCHA v2 into my PHP file

Convert every two values of an associative array into key-value pairs

how to retrieve the first and last instance of a row in pdo dataset

Vimeo API: how to save a vimeo into a subfolder?

api response laravel doesn't show

How can I make a full text index of the column?

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Display the WooCommerce product price inside a custom function

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

How to load Codeigniter 4 lang file into an array variable

Display a product custom field only in WooCommerce Admin single orders

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Whats the point of running Laravel with the command 'php artisan serve'?

php code to send checkbox form results to email

About Contact Privacy policy Terms and conditions