diffrent style for post single page

You could listen for the $_SERVER[‘HTTP_REFERER’] and add a class to the body depending on that referer add_filter( ‘body_class’,’wpse_body_classes’ ); function wpse_body_classes( $classes ) { if ( is_page( ‘event’ ) ){ // event is the page slug of the page we wish to add the class for if( wp_get_referer() == ‘/url/of/get_involved’ ){ $classes[] = ‘my-light-bg’; … Read more

Custom post type not respecting template hierarchy

From what you’ve told us, your single-case-study.php should be the correct file. To help troubleshoot, add this line to your header.php: <!– <?php global $template; print_r($template); ?> –> Then view the source of a single case study and see which template WP is outputting. Once you have identified the file, if the solution isn’t clear, … Read more

Display custom post types in wp_list_pages

To simplify things, first make your archives actual Archives – not Pages. That will help you later on in listing the correct content. unregister_post_type(‘blog’); unregister_post_type(‘event’); unregister_post_type(‘news’); Unregistering the post type won’t delete any content, it will just ensure that when you re-register them, the settings will take effect. Tweak your register_post_type calls which should look … Read more

Conditional: IF current user has NOT commented on current post (not including post author)

[EDIT] Here is the modified code: $post_id = get_the_ID(); // ID of the current post. $user_id = get_current_user_id(); // ID of the current user. $post_author_id = get_post_field( ‘post_author’, $post_id ); $is_post_author = ( $user_id && $post_author_id == $user_id ); $can_comment = $is_post_author; /* * If $can_comment is not yet TRUE, then it’s because either: * … Read more

Is it possible to customize the post according to post format in single.php?

Yes, it is possible. The easiest and very readable way would be to do this like TwentyX themes do – using get_post_format and get_template_part functions. Let’s say that your current single.php file looks something like this: <?php get_header(); ?> … <?php while ( have_posts() ) : the_post; ?> <article …> … </article> <?php endwhile; ?> … Read more

How to put single-***.php in a specific folder?

Changing how WordPress loads files can be very difficult and potentially destroy logic other plugins rely on. Instead, I usually make use of get_template_part() in this case like so single.php <?php get_template_part(‘singles/single’, get_post_type()); And your files like singles/single-foo.php (for CPT foo) singles/single-bar.php (for CPT bar) singles/single.php (this is the default)

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