• 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

Store multiple fields in JSON column (Nova CMS)

PHP function Not Working As Expected From functions.php Include File

Get WooCommerce products from specific category

Mysqli Output to a table

how to loop through json response data using ajax jquery?

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

Adding custom body class to the custom archive pages

Magento 2 - Controller returning blank page

add uri parameter to Route name in laravel

Laravel: HTML in notification

Woocommerce product attributes with hierarchy like categories

WooCommerce Additional Information - if empty, hide

Python - Include another Python script

How to create a cookie to store the timestamp of when a page is first loaded with php

About Contact Privacy policy Terms and conditions