posts_nav_link pulling in multiple post types

query_posts should be avoided at all costs. This is not just my emphasis, but the codex’s as well Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query … Read more

PHP if have image display image, if else text

I posted this question on stackoverflow, and got this answer from @cmorrissey. Credit goes to him for this code. <?php if($novus_logo_upload = get_option(‘novus_logo_upload’)){ ?> <!– Logo Image –> <a href=”https://wordpress.stackexchange.com/questions/149443/<?php bloginfo(“url’); ?>/home” title=”<? echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>” rel=”home”> <? echo ‘<img class=\”logo”\ src=”‘.$novus_logo_upload.'” width=\”100%”\ />’; ?> </a> <?php } else if($novus_logo_text … Read more

Dynamic CSS through PHP issue

Wow I am an idiot. Ok, here is my error. .contain-to-grid .top-bar { background-color: <?php echo $novus_nav_color; ?>; } I needed to just echo the variable and it was trying to call a string.

Dynamically Generate Functions and Hooks

Since Milo is a genius, I got this done much simpler by just looping through the array inside of the function, instead of trying to generate a new function dynamically for each item. The array contains ‘slug’ and ‘title’ attributes, and here’s the function: function cx_product_field() { global $fieldset; foreach ( $fieldset as $field ){ … Read more

Shortcode won’t execute

You’re using your shortcode function to directly output something (using echo). Shortcodes are supposed to return the desired output rather than echo it directly. You could use output buffering to “catch” anything that’s outputted (for example, via echo) in an output buffer instead of directly outputting it, and retrieve the content of the buffer afterwards. … Read more

WordPress loop is not working

custom-header.php <!– Start Top Header affix nav–> <div id=”affix” data-spy=”affix” data-offset-top=”94″ data-offset-bottom=”0″> <!– **** START – NAVBAR SCROLLSPY FIX DO NOT REMOVE **** –> <div id=”top” class=”hide”></div> <!– **** END – NAVBAR SCROLLSPY FIX DO NOT REMOVE **** –> <!– **** START – NAV **** –> <nav class=”navbar navbar-default navbar-shrink”> <div class=”container”> <div class=”navbar-header”> <!– … Read more

Replace Post-Title with variable

For hiding Title in admin panel the easiest way is using CSS. Another better way is using front-end submitting plugins. Follwoing code help you to change post title. add_filter( ‘the_title’, ‘replacePostTitle’, 100, 2); function replacePostTitle($title, $id){ if (is_feed()) $return $title; //do some magic here return $new_title; }

Shortcode for a Series of Elevating Image Files, Excluding a Range?

You can try the following code snippet: /** * Shortcode for a series of elevating image files, excluding a range * * @link http://wordpress.stackexchange.com/a/151408/26350 */ add_shortcode( ‘episode’, ‘episode_shortcode’ ); function episode_shortcode( $atts = array(), $content=”” ) { //———————– // Settings: // $path=”/path/to/files”; $ext=”jpg”; //———————– // Shortcode input: $atts = shortcode_atts( array( ‘num’ => 0, ‘title’ … Read more

Setting a default thumbnail url if no thumbnail

Just set up a condition to check that thumb_id isn’t empty. If it is, use your alternative image. Pretty simple stuff. <?php $thumb_id = get_post_thumbnail_id(); if ( $thumb_id ) { $thumb_url = wp_get_attachment_image_src($thumb_id,’thumbnail’, false); $thumb_url = $thumb_url[0]; } else { $thumb_url=”http://www.website.com/img/default.jpg”; } ?> <div class=”content” style=”background-image:url(<?php echo $thumb_url; ?>);”>