Compare post-IDs within WP_Query? (Less than / Greater than)

I ended up using something like this: function filter_where( $where=”” ) { global $post, $prev_next; $the_ID = $post->ID; $where .= ” AND wp_posts.ID “; $where .= $prev_next==’next’ ? “< $the_ID” : “> $the_ID”; return $where; } add_filter( ‘posts_where’, ‘filter_where’ ); $nextProjQuery = new WP_Query( $filtered_query_args ); remove_filter( ‘posts_where’, ‘filter_where’ );

Selectbox in admin panel function linking to CSS

Not Recommended <?php if(theme_get_option(‘theme_style_options’) == ‘style1’): ?> <link rel=”stylesheet” type=”text/css” media=”all” href=”https://wordpress.stackexchange.com/questions/55754/<?php echo get_template_directory_uri(); ?>/style1.css” /> <?php elseif(theme_get_option(‘theme_style_options’) == ‘style2’): ?> <link rel=”stylesheet” type=”text/css” media=”all” href=”<?php echo get_template_directory_uri(); ?>/style2.css” /> <?php elseif(theme_get_option(‘theme_style_options’) == ‘style3’): ?> <link rel=”stylesheet” type=”text/css” media=”all” href=”<?php echo get_template_directory_uri(); ?>/style3.css” /> <?php endif;?> OR <link rel=”stylesheet” type=”text/css” media=”all” href=”https://wordpress.stackexchange.com/questions/55754/<?php echo get_template_directory_uri(); ?>/<?php … Read more

Get posts inside Get terms problem

When you do the following in your code $posttags = get_the_tags($item->term_id);, $item is referring to a post object, not a term object. Therefore, term_id is an invalid property. This should be throwing a PHP notice. While not certain, I think what you are intending to do is: $posttags = get_the_tags($item->ID); since get_the_tags takes a post … Read more

Using WP Category Lists Plugin to Dynamically Display Category (PHP)

I found a much easier way to do this. I called this PHP in the Loop: if ($paged == 0) $offset = 0; else $offset = ($paged – 1) * 11; global $post; $category = get_the_category($post->ID); $category = $category[0]->cat_ID; $myposts = get_posts(array(‘numberposts’ => 11, ‘offset’ => $offset, ‘category__in’ => array($category), ‘post__not_in’ => array($post->ID),’post_status’=>’publish’)); foreach($myposts as … Read more

Loop with slider (slider not loading)

The simplest explanation is that the HTML rendered in your code does not match what you’re actually looking for. Without seeing the JS responsible for the slider, it’s impossible to say where you went wrong, but you should compare the mocked-up version (that works) with what you’re actually getting (HTML source after page render) to … Read more

Where to put snarfer.php?

Yes, templates files belong to a theme and therefore into the theme directory. The Codex text is a bit vague currently. You should edit that until it is easy to understand. 🙂

How can I randomize a Nextgen Gallery Slideshow [closed]

There’s a function defined in nggfunctions.php that you can use directly in the template page: /* nggShowRandomRecent($type, $maxImages, $template, $galleryId) – return recent or random images * * @access public * @param string $type ‘id’ (for latest addition to DB), ‘date’ (for image with the latest date), ‘sort’ (for image sorted by user order) or … Read more

Checking if Post Title is Unique as Loop Criteria

In case anyone’s wondering I managed to get this fixed with a pointer about using var_dump(). Here’s the modified loop. function build_home_id ($pcode_id, $assigned_id_no) { //$cmplt_id = $pcode_id . “-” . number_pad($assigned_id_no, 3); // Gets postcode string and calls the number padding function to add the leading 0’s do { $cmplt_id = $pcode_id . “-” … Read more

How to sanitize uploaded file filename from a plugin?

I found a way. Change the lines on wordpress-form-manager plugin direcoty -> types -> file.php (around line 109) From: if($fileNameFormat == “%filename%”){ $newFileName = $pathInfo[‘filename’]; } To: if($fileNameFormat == “%filename%”){ //Sanitize the filename (See note below) $remove_these = array(‘ ‘,’`’,'”‘,’\”,’\\’,”https://wordpress.stackexchange.com/”,’%’); $newFileName = str_replace($remove_these, ”, $pathInfo[‘filename’]); //Make the filename unique $newFileName = time().’-‘.$newFileName; }