How to add source code into wordpress post really?

Since you are self hosting the blog, you will need to: Install the SyntaxHighlighter Evolved plugin. Make sure that you enable the plugin on your blog (this is not done automatically after install). You should now be able to add the code to a post or page via either the visual or text editor. [code … Read more

get_page_template returning nothing

Have you tried is_front_page()? It should do what you’re looking to do. Unless you’ve set up front-page.php with the Page Template commented header syntax that identifies the file is a Page Template, I don’t think you can use the is_page_template() or get_page_template() functions. As for the category page, if you are loading category-foo.php, then aren’t … Read more

How to avoid loading wp-load.php from external php scripts?

Pretty much wp-load.php is the only way to go. I don’t think there is really another way to load the WordPress functions safely… You can account for path variations by recursively including it from any file where you need it though… eg. function file_find_require($file,$folder=null) { if ($folder === null) {$folder = dirname(__FILE__);} $path = $folder.DIRECTORY_SEPARATOR.$file; … Read more

What kind of data is that?

It’s a serialized string. Here’s a good description of what it is: A PHP array or object or other complex data structure cannot be transported or stored or otherwise used outside of a running PHP script. If you want to persist such a complex data structure beyond a single run of a script, you need … Read more

My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

Ok, I managed to solve this issue because I was using the wrong WP functions to point my child themes directory and thus my bundled javascript script. I cleared out my functions.php file and added the below and it all works now: function load_js_files() { wp_enqueue_script( ‘script’, get_stylesheet_directory_uri() . ‘/js/scripts-bundled.js’, array ( ‘jquery’ ), 1.1, … Read more

WordPress wp_insert_post() returns 0 but not not wp_error

It appears that you can ask wp_insert_post() to return a WP_Error on failure by setting the 2nd parameter to true (it defaults to false). So if you change $new_article_id = wp_insert_post($new_article); to $new_article_id = wp_insert_post( $new_article, true ); in your code, you should get WP_Error objects back that you can then inspect.

Proper indentation of code generated inside hooks

I don’t think correct global indentation is possible without massive (and inefficient) output buffering to change it. Since you are primarily interested in this for debug purposes I suggest using some tool that will format and color-code output (of any page btw, not just those that you control). Firebug and View Source Chart work nicely … Read more

Need resource on available functions and objects

Hi @menardmam: Let’s try with what I wrote in the question : $cat->cat_name. How can I know that cat_name is a method that return something from $cat from get_the_category() function? Frankly the best way to know an answer like that is to use a debugging IDE and to trace through the WordPress core source code. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)