Minor css-change based on topmenu – how?

My answer adds a class to the <body> element via the body_class filter. This is probably the easiest way to apply extra formatting to any element on the page. The added classes are wpse14430_products, wpse14430_services or wpse14430_contact (based on the slugs of the top pages in your example). Using wp_nav_menu() If you use wp_nav_menu() to … Read more

Remove line breaks in wp_list_categories()?

I came to a solution for this by reviewing the WordPress Codex. The trick is to turn off the automatic echo of wp_list_categories, and then use str_replace(). My example follows: <?php $variable = wp_list_categories(‘child_of=270&style=none&echo=0’); ?> <?php $variable = str_replace(‘<br />’, ”, $variable); ?> <?php echo $variable; ?> The only real change in your query is … Read more

How to show the real post date in a draft

Yes, as you – so far – have no publish date. You could use $post->post_modified, which will always be the date of the latest modification to the post data. Debug: Try hooking into the filter and dump both vars: function date_dump_callback( $date, $d ) { echo ‘<pre>’; print_r( $date ); print_r( $d ); echo ‘</pre>’; … Read more

get_parent_theme_file_path vs. get_template_directory

Is there a specific reason to use get_parent_theme_file_path() over get_template_directory() Yes. This new function comes with a filter Filter parent_theme_file_path And argument to the file path If you take a look at the get_parent_theme_file_path() source, it’s just returning get_template_directory() with extra functionality like if a file is given as an argument to the get_parent_theme_file_path it … Read more

Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation

this is very simple to do… // next function next_shortcode($atts) { // global $post; -unnecessary return ‘<div class=”nav-next”>’.next_post_link( ‘%link’, ‘%title <span class=”meta-nav”>’ . _x( ”, ‘Next post link’, ‘ ‘ ) . ‘</span>’,true ).'</div>’; } add_shortcode( ‘next’, ‘next_shortcode’ ); //prev function prev_shortcode($atts) { //global $post; -unnecessary return ‘<div class=”nav-previous”>’.next_post_link( ‘%link’, ‘%title <span class=”meta-nav”>’ . _x( … Read more

How to get the clean permalink in a draft?

This is a little “hacky”, but when you call get_permalink and you need the permalink for a draft, provide a clone of your post object with the details filled in: global $post; if ( in_array( $post->post_status, array( ‘draft’, ‘pending’, ‘auto-draft’ ) ) ) { $my_post = clone $post; $my_post->post_status=”publish”; $my_post->post_name = sanitize_title( $my_post->post_name ? $my_post->post_name … Read more

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