• 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 map the two arrays with a duplicate value?

With doctrine ODM, can I embed many subdocuments in a main document?

Laravel Mix Uncaught ReferenceError: $ is not defined

Normalize DateInterval in PHP

PHP Find Array Index value in multi-line array

How can I format this number correctly using PHP?

How to make autocomplete work in foreach php loop? (vscode, intellisense)

Laravel Sanctum CSRF not authenticating

Update Order custom Field value with WooCommerce REST API

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

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

passwordless LDAP login and get user information using Kerberos ticket in PHP

How to Display Data in Yajra Datatables Laravel 7?

could not find driver Debian SQL Server PHP

wordpress : How to specify the cause "This site can’t be reached"

About Contact Privacy policy Terms and conditions