Condition function for is parent category?

I’m not sure I fully understood your question, but wrapping a function inside a new function will make it shorter. For example, do the following in your functions.php file: function is_parent($slug){ if(is_category($slug)){ return true; }else{ return false; } } And then simply use it like: if(is_parent(‘slug’)){ // do something }

Custom Menus, Widgets & Conditional Statements

if you want to show the menus only on child pages then you need to change your conditional statement: global $post; //only on children of 269 if (‘269’ == $post->post_parent){ //menu for Sport & Fitness pages ?> <div id=”seventh” class=”widget-area” role=”complementary”> <?php dynamic_sidebar( ‘sidebar-7’ ); ?> </div><!– #second .widget-area –> <?php //only on children of … Read more

Conditions for Users and Visitors

EDIT You just need to add a custom hook to anything after parse_request and attach your coming soon content or redirect to that hook as you see fit. Hooking earlier then parse_request will cause WP to not be able to redirect /wp-admin/ to wp-login.php. You could also use php redirect if that is the behaviour … Read more

How to do conditional publishing?

That’s because the hook “transition_post_status” is called: After the post has been published or updated in the database After the status has been updated in the database. Based on your problem statement, I believe the hook you want is “pre_post_update”, as stated in relevant WordPress source code: /** * Fires immediately before an existing post … Read more

Loading Scripts on Specific Pages

I’d suggest moving the script registering into the init action, and moving the enqueue(s) into a callback hooked onto wp_print_scripts. Eg. add_action( ‘init’, ‘register_those_scriptsNstyles’ ); function register_those_scriptsNstyles() { wp_register_script( .. your script params .. ); wp_register_style( .. your style params .. ); ..etc.. } add_action( ‘wp_print_scripts’, ‘enqueue_those_scriptsNstyles’ ); function enqueue_those_scriptsNstyles() { if( !is_page( ‘some-page’ ) … Read more

Conditional tag affecting taxonomy term and its children?

I have a handy little function that i based on post_is_in_descendant_category function it expends the is_tax to check if its the term or any of his children function is_or_descendant_tax( $terms,$taxonomy){ if (is_tax($taxonomy, $terms)){ return true; } foreach ( (array) $terms as $term ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $term, … Read more

Conditional Ajax inclusion

When you call admin-ajax.php no query is being produced so is_page() or is_category() or any query based conditional tag will never return true. A better way would be to include your files inside the ajax callback, meaning something like this: add_action(‘wp_ajax_PAGE_ONLY_ACTION’,’PAGE_ONLY_Function’); function PAGE_ONLY_Function(){ include TEMPLATEPATH . ‘/ajaxLoops/ajax-open_client_editform.php’; /** * do your page only ajax */ … Read more

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