• 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

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

disable two buttons after clicking another button

Could not decode a text frame as UTF-8.

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

PHP: Print caught exception like Xdebug

Fatal error: [] operator not supported for strings

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Display a product custom field only in WooCommerce Admin single orders

How to install php_imagick on wamp64

Add and update products to session cart in Laravel

Add restriction to WooCommerce coupons by allowed user ID

Invalid value in field "itemtype" in Google Search Console

How to add class name to an existing tag in php

Call to a member function fetch_field() on a non-object MySQLiDB

Implode array with array of glue strings

About Contact Privacy policy Terms and conditions