• 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

Add custom text under order details on WooCommerce My account view order pages

Parsing JSON File to array in PHP

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

Group data in a multidimensional array based on two columns

PHP - Store information with NO database

Send Outlook 2010 email using PHP

SQL AVG() to 2 decimals

Populate Dynamic Dropdowns List in Codeigniter

Put content of wordpress page inside div

How to delete old images from public folder on update using Laravel

How to read laravel_session cookies saved in cookie memory of browser in client side?

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Show Custom Data in Woocommerce Order Details Admin Area

Handling expired token in Laravel

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

About Contact Privacy policy Terms and conditions