• 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 sort by a custom appended relation to model

How to retrieve Active Directory group policy maximum password age using LDAP

add " ? " in url via htaccess RewriteRule

How to add a heading in between checkout fields of WooCommerce

How to debug in WooCommerce 3+

I cannot create a auto generated date time in mysql workbench

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Getting output of MS stored procedure on php call

500 Internal Server Error on Ajax request. Not sure the origin of the problem

How to make a foreign key not using primary key

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

Testing subscription renewals on Stripe

Override default Auth routes in Laravel 7

Target class controller does not exist - Laravel 8

Adding hreflang tags automatically in WordPress subdirectory multisite

About Contact Privacy policy Terms and conditions