Get page id of current page from template [duplicate]

To get the ID of the page being queried from outside the loop or before the global post object has been set, use get_queried_object_id(). <?php /** * Template Name: Contact Page */ get_header(); ?> <?php $page_id = get_queried_object_id(); echo get_post_meta( $page_id, ‘contact_page’, true); ?> <?php get_footer() ?>

Custom page for WooCommerce’s /product-category/

product-category URL uses taxonomy-product-cat.php which calls archive-product.php you will need to override it by creating the same file with the same name in themefolder/woocommerce/archive-product.php You can open any file in templates folder in the WooCommerce plugin and you will find a line in the very top comment describes how to override the file. Don’t forget … Read more

Query from a different database than the default

I don’t know why the mysql_connect isn’t working inside WordPress. But an easier way of doing it would be to use the $wpdb class. Try replacing your code with this: $second_db = new $wpdb( ‘user’, ‘pass’, ‘dbname’, ‘host’ ); $q = $second_db->get_results( ‘SELECT * FROM vars’ ); var_dump( $q ); and see if you get … Read more

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