• 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

Add New Parameter to Existing URL using htaccess

Get all WooCommerce products within own plugin

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Remove categories with all childs derived from parent category

Yii2: How to download backup files using spanjeta/yii2-backup?

PHP using str_starts_with for array to exclude same as with wildcard

Read users and passwords from a txt file

Override default Auth routes in Laravel 7

In PHP, which is faster: preg_split or explode?

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

Combining a describing and one array with data

Undefined variable in Laravel 8 project (php 7.4)

Class AppHttpControllersUserController Does Not Exist

Custom API and cunsuming in php?

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

About Contact Privacy policy Terms and conditions