is_page_template & is_page in functions.php not working

Use wp_enqueue_scripts instead on init. This will ensure you the template is already loaded. add_action(‘wp_enqueue_scripts’, ‘maps_scripts’); Or you try to check the template using get_page_template_slug() instead of is_page_template: $tmp = get_page_template_slug($post_id); // provide page/post ID if(‘page-about.php’ == $tmp) { // enqueue scripts here } Note that you don’t need to register scripts before enqueueing them. … Read more

Page attribute template dropdown not displayed even the syntax is correct

If you’re wanting to enable the Page Template dropdown for a custom post type, you have to enable support for “page attributes” when you define your CPT. You should currently have something like register_post_type(‘foo’, array(‘labels’ => array( … ), ); You need to add ‘supports’: register_post_type(‘foo’, array(‘labels’ => array( … ), ‘supports’ => array(‘title’, ‘editor’, … Read more

Custom page template

Your code will only display a list of your posts if the page that is using that template is set to be the Posts Page (in admin settings). If you want any other page to display a list of posts, then you need to write a custom query inside the template. E.g. using WP_Query: $args … Read more

Exclude pages with certain template from wp_list_pages

Daniel, exclude parameter doesn’t accept array. Use your code this way: $exclude = []; foreach(get_pages([‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘page-templates/page-noindex.php’]) as $page) { $exclude[] = $page->post_id; } $args = array( ‘exclude’ => implode(“,”, $exclude), ‘title_li’ => ”, ‘sort_column’ => ‘menu_order, post_title’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’ ); wp_list_pages($args); I think you can refactor it … Read more

Run Product Filter Javascript On Page Template

In WordPress, you should use wp_enqueue_script() to load JavaScript files, and wp_enqueue_style() to load CSS files, and the functions should be called using the wp_enqueue_scripts action hook. Additionally, the theme needs to call wp_head() (in header.php) and wp_footer(). And to enqueue a script only on specific pages, you would use a conditional tag like is_page() … Read more

Build dynamic page from cURL (HTML page) response with plugin

To make this work with WordPress use the AJAX API. While that technically refers to Javascript it will handle any request if the appropriate values are sent. You would create a callback like this one form the Codex: add_action(‘wp_ajax_my_action’, ‘my_action_callback’); function my_action_callback() { global $wpdb; // this is how you get access to the database … Read more

How to Set a Custom Template for Blog Posts

As I understand it, you can’t use Page Templates that way; you need to edit your index.php file instead. See this chart for more detail on how the hierarchy works and this post for a detailed explanation. By specifying “Blog” as the “posts page” on the Settings > Reading tab, you are telling WordPress “this … Read more

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