• 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 give apache permission to write to home directory?

Remove product downloads section in woocommerce email notifications

phpunit - testing is painfully slow

Laravel eloquent update record without loading from database

CodeIgniter 4: Like and Dislike Functionality

Adding Multiple Custom Post Types in Wordpress

Distribute array row data to make multiple new rows

Create a new line whenever an array value reaches more than 10 characters

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

I want to store data in new index as per my key in php [duplicate]

Symfony/Form add attribute based on the data

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

Yii2 select2 database exception number of bound variables does not match number of tokens

Using Associative arrays

Unable to create lockable file - Laravel 8 & PHP 8

About Contact Privacy policy Terms and conditions