• 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

Store multiple fields in JSON column (Nova CMS)

Valet, Xdebug after reboot Big Sur not working

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Wordpress how to get the post thumbnail inside a figure tag

Cannot pass null argument when using type hinting

Pass an image through AJAX [duplicate]

mysql slow on updates for a well optimized query

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

How to map the two arrays with a duplicate value?

What is the difference between client-side and server-side programming?

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

Merge column values from two arrays to form an indexed array of associative arrays

send email using gmail-api and google-api-php-client

Get all WooCommerce products within own plugin

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

About Contact Privacy policy Terms and conditions