Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS

I wanted to achieve the same thing.. What I ended up doing was creating a function that collects the Kirki variables (see here about the use of variables in Kirki) and writes them to a scss.. $file = get_template_directory() . ‘/sass/custom/_custom_vars_mixins_options.scss’; if(file_exists($file)){ $output = “”; $variables = Kirki::get_variables(); foreach ( $variables as $variable => $vvalue … Read more

How do I check if there is a tag in the title

Put this in your loop: <?php $title = get_the_title(); $posttags = get_the_tags(); if( $title && $posttags ) { $result = find_tag_in_title( $title, $posttags ); var_dump( $result ); // dump result } ?> Put this in your functions.php file: <?php function find_tag_in_title( $title, $posttags ) { foreach( $posttags as $tag ){ if( strpos( strtolower($title), strtolower($tag->name) ) … Read more

WordPress call post-ID in jquery

This question is more of a js/jQuery is then WordPress. I am not going to post a working answer as It is hard to read the html given. And I think how you are doing it is not a effective solution. My answer should guide you towards better solution. First of all you do not … Read more

How to display meta_value array?

The SQL you want would be: $sql = ” SELECT DISTINCT post_id FROM $wpdb->posts, $wpdb->postmeta where $wpdb->postmeta.meta_value=”2015/06/03″”; $results =$wpdb->get_results($sql); But there is no reason to be involving the $wpdb->posts table at all, since the post_id value is a $wpdb->postmeta table column. $sql = ” SELECT DISTINCT post_id $wpdb->postmeta where $wpdb->postmeta.meta_value=”2015/06/03″”; $results =$wpdb->get_col($sql); Note that I … Read more

Output column number according to active sidebars

Use the array_filter() function, which will remove every array element that has false as the value. Then you can count the array length. So your example would look like this: $sidebars = array( is_active_sidebar( ‘footer-4’ ), is_active_sidebar( ‘footer-3’ ), is_active_sidebar( ‘footer-2’ ), is_active_sidebar( ‘footer-1’ ), ); $active_sidebars = array_filter($sidebars); echo ‘col-‘.count($active_sidebars);

How do I get the index for a custom post?

For example if there are 10 custom posts, and No. 1 is the oldest, and they happened to select the 3rd oldest one, they want it to say “No. 3”. There is a more elegant way than that function: $args = array( ‘post_type’ => ‘book’, ‘fields’ => ‘ids’, ‘ignore_sticky_posts’ => true, ‘orderby’ => ‘post_date’, ‘order’ … Read more

Manually Create PHP Page For A Redirect

I guess you are talking about a specific page, for example domain.com/page? So you can create a generic page template (and select it for the page in WordPress admin panel) or create a template for the specific page. See instructions here. In this template you can add your php code for the redirect. If this … Read more