Showing Different Code on Pages With Different Layouts

function add_js_one_col_wpse_107240() { if (is_page()) { $pobj = get_queried_object(); if(!empty(get_post_meta($pobj->ID,’one-col’,true)) { wp_enqueue_script(/* … */); } else { wp_enqueue_script(/* … a different script … */); } } } add_action(‘wp_enqueue_scripts’,’add_js_one_col_wpse_107240′); get_queried_object will get you the page information. It will be a WP_Post object on a “Page”. global $post should probably work too, but this is cleaner. Use … Read more

Query pages based on tags

This is because you haven’t mentioned post_type here and by default post_type is ‘post’ and hence it is missing the pages, add the below in your query ‘post_type’ => array( ‘post’, ‘page’ ) Like this $articles = new WP_Query( array( ‘showposts’ => -1, ‘tag’ => $tag, ‘meta_key’ => ‘date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, … Read more

How do I reference the front page’s parent Page object?

You can get the ID of the front page via get_option( ‘page_on_front’ ). (See also: WordPress option reference.) From there, you can query the page object via get_post(): $frontpage = get_post( get_option( ‘page_on_front’ ) ); Then the content is in the $frontpage object: $content = $frontpage->post_content;

wp_query issue with post_type = page

If your goal is to load the selected custom template for each page within the loop, then you’re actually pretty close to that. You’re getting the value of _wp_page_template, but then you’re not doing anything with that template, you’re just loading content-page.php for each of those pages with the line get_template_part( ‘content’, ‘page’ );. If … Read more

How to get tagged pages to show up with tagged posts?

You need to use pre_get_posts hook. Paste this code to your themes functions.php file. add_action(‘pre_get_posts’, ‘wpse_pre_get_posts’); function wpse_pre_get_posts($q) { if( $q->is_main_query() && $q->is_tag() ) { $q->set(‘post_type’, array(‘post’,’page’) ); } }

on page creation few inline style properties gets removed

Thought the language is a bit confusing, if you check the Codex and pay attention to the difference between the Admin and the Super Admin you should be able to see what is happening. In the case of single site WordPress installation, Administrators are, in effect, Super Admins. As such, they are the only ones … Read more

Use page template for custom $_GET content

You can use the template_include filter to load a template file from your theme: add_filter( ‘template_include’, ‘my_page_template’, 99 ); function my_page_template( $template ) { if ( isset( $_GET[‘info’] ) && $_GET[‘info’] == ‘some_value’ ) { $new_template = locate_template( array(‘my-template.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; … Read more

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