Returning Variables back into a template

There’s filters for that. Example: add_filter( ‘template_filter’, ‘wpse_102706_filter_callback’, 10, 2 ); function wpse_102706_filter_callback( $defaults, $case ) { $args = wp_parse_args( array( ‘some_key’ => ‘some_modified_value’ ), $defaults ); return $args } Then in your template just add in the defaults: apply_filters( ‘template_filter’, array( ‘some_key’ => ‘default_val’ ), ‘single’ ); More info in Codex about the Plugins … Read more

Settings API enable default settings on theme install?

You can pass defaults to get_option. The second parameter is a fallback. $default (mixed) (optional) The default value to return if no value is returned (ie. the option is not in the database). Default: false So, for example, instead of: $options = get_option(‘plugin_options’); You’d want: $options = get_option(‘plugin_options’,array(‘display_sidebar’ => true)); Or you can insert your … Read more

how to pull wordpress post comments to a external page

add to your loop and replace it with the the_permalink() function something like this: <?php // Include WordPress define(‘WP_USE_THEMES’, false); require(‘./blog/wp-load.php’); ?> <div> <p style=”font-size:18px;color:white;font-wieght:700;”>Recently Asked Questions</p> <?php query_posts(‘showposts=3’); ?> <?php while (have_posts()): the_post(); ?> <div id=”faq”> <a href=”https://wordpress.stackexchange.com/questions/7919/<?php the_permalink() ?>”><?php the_title() ?></a><br /> <?php the_time(‘F jS, Y’) ?> <?php the_excerpt(); ?> <?php comments_popup_link(); ?> … Read more

Is there any need to use both wp_reset_postdata and wp_reset_query together?

There’s no need to use them both. You should only use wp_reset_query(), if you modified query with query_posts() (which you should avoid). This function also call wp_reset_postdata() – http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/query.php#L95 So it’s better to use wp_reset_postdata() after running separate query.

First post of each category

It’s not possible to get one posts per category with one simple query, and even a complex query will take more time than 3 separate query. So, if you want simplest, then this is the solution – $cats = array(‘lifestyle’, ‘fashion’, ‘beauty’); $exclude_posts = array(); foreach( $cats as $cat ) { // build query argument … Read more

How to remove menus section from WordPress theme customizer

Try nav_menus instead of menus with remove_panel() function mytheme_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->remove_section( ‘title_tagline’); $wp_customize->remove_section( ‘colors’); $wp_customize->remove_section( ‘header_image’); $wp_customize->remove_section( ‘background_image’); $wp_customize->remove_panel( ‘nav_menus’); $wp_customize->remove_section( ‘static_front_page’); $wp_customize->remove_section( ‘custom_css’); } add_action( ‘customize_register’, ‘mytheme_customize_register’,50 ); Hope this will helps you. Thank you!

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