• 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

Download & Save Zoom Recording in directory by PHP

how to redirect the user back to desired URL after login page in PHP?

Laravel eloquent update record without loading from database

Laravel print last executed SQL query with Query log

Custom post type single page not working

CSS file not imported in laravel blade view

Coinpayments create_transaction "ERROR: Invalid command!"

Add restriction to WooCommerce coupons by allowed user ID

jQuery Ajax Post with data

Don't show recurring price for WooCommerce subscriptions worth 0$

CodeIgniter 3 is generating a session file on each request, why?

Laravel Unknown Column 'updated_at'

Display a success custom notice after Placing an Order in WooCommerce

Fatal error: Array callback has to contain indices 0 and 1

add uri parameter to Route name in laravel

About Contact Privacy policy Terms and conditions