• 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

WooCommerce Additional Information - if empty, hide

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Detect emoticons in string

Increase value by 1 on button click

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Problems getting instance of UploadedFile in Yii2

wp_remote_get() not passing authentication

Add rows to Single product Additional information table in WooCommerce 3.6

How to create a video stream from a single dynamic image in PHP

PHP: How to solve ob_start() in combination imagepng() issue?

Prevent blank space in pdf pages (DomPdf)

How to add automatically collapse/expand in content wordpress (single.php)?

Navigation idle on content download

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Filter WooCommerce related products by Polylang language

About Contact Privacy policy Terms and conditions