• 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

SQL to convert multiple rows into a single row of variable length

Live search query using JS and PHP for QA forum

Adding the custom page with add_menu_page function on Wordpress

Reorder attribute dropdown terms in Woocommerce single variable products

PHP Slim Framework request using withAttribute error

Star rating with half star support

Correct way to use LIKE '%{$var}%' with prepared statements?

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

Reorder attribute dropdown terms in Woocommerce single variable products

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

jQuery Ajax Post with data

How do I call Validator from a namespace with an already existing Validator class

protect images from being copied

how to sort by a custom appended relation to model

About Contact Privacy policy Terms and conditions