• 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

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Get WooCommerce product variation attribute terms in admin products general box

Google Calendar API batch request PHP

How do I set the maximum php memory limit

Pages are working fine on localhost but not running on the hosting server

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

Check if user online laravel

Execute only one time and then wait set period of time before executing again

Chunk and transpose a flat array into rows with a specific number of columns

Popup Window and PHP form

Multiple order by in WooCommerce

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Spam Filter in Contact Form

How do I get friend list from Friends table with counts of friends of my friends

ConstraintViolationListInterface to Exception in Symfony

About Contact Privacy policy Terms and conditions