Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Function to check if the current Page is a parent or not.
* @return bool true (1) if the current Page has children else false (0)
*/
function wpdd_is_parent_page() {
// Load details about this page.
$post = get_post();
<?php
//Add dynamic class to posts
//dynamic_classes_oxygen_repeater.php
//Add this into a codeblock
<style type="text/css">
.post-<?php the_ID() ?> #DIV_ID_HERE{
background-color:<?php the_field('ACF_FIELD_HERE'); ?>;
}
<?php
//Add to Advanced Scripts
add_shortcode( 'repeater_post_class', 'lit_post_class_sc' );
/**
* Shortcode for adding post classes inside Oxygen Repeater
*/
function lit_post_class_sc( $atts, $content = null ) {
$postclasses = join( ' ', get_post_class() );
//Get the Custom Post Type
// -1 means we get all the posts type.
<?php
$things = get_posts(['post_type' => 'CPT','posts_per_page' => -1]);
//Start with 0 calories
$total = 0;
//Then Loop through all the posts in your CPT
Foreach($LotsofPosts as $singlePost):
//well grab the calories from each post
/*
* Add post object field on the CPT you want to display
* In the post object field select the CPT post you want this post to show on
*
* Example:
* 2 CPT's - Tours and Reviews
*
* To show reviews on the relevant tours:
* - Add the post object field to the reviews CPT
* - Select the tours that I want the reviews to show on inside the Review post
/*Put this in the header*/
html{visibility: hidden;opacity:0;}
/*Put this in the footer*/
html {
visibility: visible;
opacity: 1;
}