How to check if I am inside the WP Theme Customizer preview?

I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ? For example: <img class=”background” src=”https://wordpress.stackexchange.com/questions/101713/<?php echo $background ?>” <?php if(is_wpThemeCustomizer()) echo ‘style=”display:none”‘ ?>/> I could do it in javascript … Read more

Get permalink and title by post name?

In the theme there is a custom post type called faq I just want to get certain post by its name (NOT by id cause no id exist). <?php query_posts(‘post_type=faq’) ?> how to get the_tile() and the_permalink() by its name? 1 Answer 1 $posts = get_posts(array(‘name’ => ‘your-posts-name’, ‘post_type’ => ‘faq’)); foreach ($posts as $post) … Read more

Template tags vs get_template_part() vs functions.php

When to use template tags and when to use get_template_part() and when to use function.php? I am confused at them. For example, if I want to show related portfolios under single portfolio, I can create a template tag named show_related_portfolios(). In contrast, I can create a file named content-related-portfolios.php, and use it like get_template_part( ‘content’, … Read more

setup_postdata is not returning any values

I am using ACF to create a custom field called facilities. Within that field is a repeater field called facility. So each store has ‘facilities’, which contains a number of ‘facility’. What I am doing is looping through each of my stores, getting the ‘facilities’, looping through each ‘facility’ within that, and displaying it. Here … Read more