When would you use $_post instead of $post?

I’ve seen some examples that use $_post instead of $post. What’s the difference and when would you use $_post instead of $post? Example: if (have_posts()) : while (have_posts()) : the_post(); if(!in_category(“some-category”, $_post )) { do_something(); } 2 Answers 2 I’m not certain, but if you’re talking about $_post as seen here: http://codex.wordpress.org/Function_Reference/in_category It’s referring to … Read more

Best way to test for a variable’s existence in PHP; isset() is clearly broken

From the isset() docs: isset() will return FALSE if testing a variable that has been set to NULL. Basically, isset() doesn’t check for whether the variable is set at all, but whether it’s set to anything but NULL. Given that, what’s the best way to actually check for the existence of a variable? I tried … Read more

Replacing string with a variable in php

I have following code in my plugin of WordPress: wp_localize_script(‘ffd_js_script’, ‘myAjax’, array( ‘ajaxurl’ => admin_url(‘admin-ajax.php’), ‘idinfo’ => $myoptionValue[idinfo], ‘index1’ => $myoptionValue[id1], ‘index2’ => $myoptionValue[id2] ) ); I want to replace ‘index1’ => $myoptionValue[id1], ‘index2’ => $myoptionValue[id2] with for($i=1; $i<= $myoptionValue[fieldcount]; $i++) { $arguments .= ‘,”index”‘.$i.’=>’.$myoptionValue[id.$i]; } So that I have wp_localize_script(‘ffd_js_script’, ‘myAjax’, array( ‘ajaxurl’ => … Read more

How do I pass variables into short-code enabled Post Snippets in WordPress 3.0?

I am using a plugin called Post Snippets. According to the documentation, it can substitute variables, such as {url} within the snippets. http://wordpress.org/extend/plugins/post-snippets/ I am unclear how to assign values from within a specific post to a variable. I tried using exec-PHP, and used the following: [exec]url = “domain.com”;[/exec] But the snippet registered no value … Read more

Take Variables Set in Functions.php and Echo Them Inside My Custom Post Template

I have the following function set up in my functions.php file to allow my custom post type “Slideshow” to work. add_action( ‘the_post’, ‘paginate_slide’ ); function paginate_slide( $post ) { global $pages, $multipage, $numpages; if( is_single() && get_post_type() == ‘lom_slideshow’ ) { $prefix = “slide{$i}”; $multipage = 1; $id = get_the_ID(); $custom = array(); $pages = … Read more