Option Tree integration of Custom CSS

never* execute code outside of hooks as you are more likely to call a function or use a variable before they were declared and initialized. your code should be function css() { if (ot_get_option(‘css’, false) != false) { echo'<style>’.ot_get_option(‘css’).'</style>’; } } add_action( ‘wp_head’, ‘css’, 100 ); *never say never, but this is a rule to … Read more

How to know if user logged in

<?php if ( is_user_logged_in() ) { echo ‘<script type=”text/javascript”>var logged_in=true;</script>’; } else { echo ‘<script type=”text/javascript”>var logged_in=false;</script>’; } ?>

Get rid of the widget Item Class=”widget-item”

The most straightforward way would be to overwrite this in your CSS file, for instance like this: .widgettitle { padding: 0; margin: 0; } Alternatively you can change the name of the class when registering your widget (possibly in your functions.php file) – look for the ‘before_title’ parameter. Here’s and example form the original twentysexteen … Read more

Get category URL for current post

Pass the category id into get_category_link(): <?php $category = get_the_category(); $link = get_category_link( $category[0]->term_id ); ?> Update Outputting in template: <?php $category = get_the_category(); $first_category = $category[0]; echo sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/274018/%s”>%s</a>’, get_category_link( $first_category ), $first_category->name ); ?>

WordPress Shortcode function display outside of widget

I think the problem lies with functions like the_title() vs get_the_title() This seem to work: if (!function_exists(‘footer_get_latest_post’)) { function footer_get_latest_post() { $footerPost=””; $args = array(‘posts_per_page’ => 1 ); $recent_posts = new WP_Query($args); while( $recent_posts->have_posts() ) { $recent_posts->the_post(); $footerPost=”<div class=”footer-post-thumb”>” . get_the_post_thumbnail(‘thumbnail’) . ‘</div>’; $footerPost .= ‘<div class=”footer-post-content”><h3>’ . get_the_title() . ‘</h3>’; $footerPost .= get_the_content() . … Read more