WPML in custom page templates

For the language filter from WPML to take effect you have to allow filters in get_posts. Default this is off. You can add suppress_filters=0 to your get_posts args and it should work. See: http://codex.wordpress.org/Template_Tags/get_posts#Parameters <ul id=”archive-list”> <?php $args = array( ‘suppress_filters’ => false, ‘numberposts’ => ‘-1’, ‘post_type’ => ‘post’, ); $myposts = get_posts($args); foreach($myposts as … Read more

How do I find if a page has a template?

This should do the trick for you. This shows what template file is stored in post_meta, if one has been selected in the admin panel: $template_name = get_post_meta( $the_query->post->ID, ‘_wp_page_template’, true ); If you want to see if the page is the homepage, use is_home() or is_front_page(). If you want to see what files are … Read more

Export csv and force download in template page

Put all the code that handles the output of the CSV before your get_header() call, then exit: <?php /** * CSV page template * */ if($_SERVER[‘REQUEST_METHOD’] == “POST”) { $fileName = date(“d-m-y”) . ‘-bv-directory.csv’; $content = “”; // content added below // Title of the CSV $content = “Name,Address,Age,Phone \n”; // Data in the CSV … Read more

is_page_template returning false

I think your problem is how your function is constructed and not your condition as such. You should not be wrapping your function and your action in a condition like this. Page templates are selected really late in the query by the main query, and I probably think that this is way to late for … Read more

Editable content on a Custom Archive page

You can use Options API or Setting API to store the data in the database. Write a plugin to create a meta box for the introduction text and show that text on the archive-unicorn.php. Or you can utilize the description parameter when you register_post_type and print it in the archive-unicorn.php like this: $unicorn_obj = get_post_type_object(‘unicorn’); … Read more

Is it safe to include a javascript file in a template’s php file?

As @N00b mentioned Yes, it is safe adding a JS script as long as it doesn’t include any sensitive information. JS is fully exposed to client, you shouldn’t do it anyway. But your situtaion it is better to create a site specific custom plugin and add JS using it. Example : function themeslug_enqueue_style() { wp_enqueue_style( … Read more

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