• 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

How to properly start Laravel 8 with Bootstrap & authentication

CSS file not imported in laravel blade view

How can I get data from PHP to Android TextView?

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

Fatal error: [] operator not supported for strings

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

Pass a select with mysqli_fetch_row to a table

I can't delete my image when it is liked because of the foreign key in mysql

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

Custom add to cart button URL for specific product in WooCommerce?

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

Set quantity minimum, maximum and step at product level in Woocommerce

Laravel dosen't connect with Oracle

PHPUnit (Phar) Fatal Error Only When Test Fails

PHP-Sort array based on another array?

About Contact Privacy policy Terms and conditions