• 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

OctoberCMS / Anonymous Global Scope

I cannot create a auto generated date time in mysql workbench

How to extract price from given url using Xpath?

Laravel MSSQL Server Connection not working

How to use React Router with Laravel?

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

sort() not affecting original array while inside foreach loop

how to youtube api data to print in toolset metabox using a button click before save-post

Laravel Sanctum CSRF not authenticating

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Update Order custom Field value with WooCommerce REST API

xdebug 3 not working in ubuntu 20.04 with docker

Yii2 select2 database exception number of bound variables does not match number of tokens

WooCommerce Additional Information - if empty, hide

Get orders by date and status woocommerce

About Contact Privacy policy Terms and conditions