• 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

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

Coinpayments create_transaction "ERROR: Invalid command!"

How to add a heading in between checkout fields of WooCommerce

Create tags in laravel post publishing

Why isn't my PHP exception working?

Adding custom body class to the custom archive pages

curl returning 301 error after migrating to https

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

how to get value from array in laravel

How to make a foreign key not using primary key

How to load Codeigniter 4 lang file into an array variable

If action is on a different page do I use fwrite function

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Not able to override collapsible.js in magento 2

PHP: Telegram Bot: Insert line break to text message

About Contact Privacy policy Terms and conditions