I’m having a problem viewing the Youtube video
You should use the_content function to process embeds. Another way is to apply the_content filter. apply_filters( ‘the_content’, $post->post_content’ );
You should use the_content function to process embeds. Another way is to apply the_content filter. apply_filters( ‘the_content’, $post->post_content’ );
So long as you’re in the loop, you can just use the standard template tags: <script type=”text/javascript” charset=”utfÂ8″> initFrame({ app_id: “”, object_id: <?php the_ID() ?>, object_title: “<?php the_title_attribute() ?>”, object_content: ‘<?php echo wp_trim_words( strip_shortcodes( striptags( get_the_content() ) ), 45 ) ?>’, object_url: “<?php the_permalink() ?>”, arguments_container: “comment-naqeshny”, width: 610 }); </script>
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
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
init is too early (it happens before the main query), use the action template_redirect instead. And for the ID use get_the_ID(). Example: if ( is_singular() ) setcookie( get_the_ID(), ‘visited’,time() + ( DAY_IN_SECONDS * 31 ) );
This should help, if you need more info: http://codex.wordpress.org/Template_Hierarchy Simply put, WordPress looks for template files in the following order for single posts: single-{post_type}.php, single.php, index.php. If you want to override the standard single.php file, that’s how (for a custom post type only, as you’re using)
<head> <meta charset=”<?php bloginfo( ‘charset’ ); ?>”> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <link rel=”profile” href=”http://gmpg.org/xfn/11″> <?php if (is_single()){ //add more keywords in regex code $badWords = array(“badwords”,”badkeyword”); $string = get_the_content(); $matches = array(); $matchFound = ”; $matchFound = preg_match_all(“/\b(” . implode($badWords,”|”) . “)\b/i”,$string,$matches); } ?> <meta name=”robots” content=”index,follow <?php echo $matchFound ?>” /> <?php wp_head() ?> … Read more
First of all, (you probably know this but..) you are fighting how WP is intended to work. You can not get the post ID directly in your custom page template because it is not displaying the post. So you will have to, as you said, send the post ID to the page template. The best … Read more
After some more Googling… New single.php looks like this: <?php get_header(); global $wp_query; if ( ! isset( $wp_query->query_vars[‘map’] ) ) { if (have_posts()) : while (have_posts()) : the_post(); the_title(); the_content(); endwhile; endif; ?> <p><a href=”https://wordpress.stackexchange.com/questions/31442/<?php echo get_permalink(); ?>?map=yes”>Map</a></p> <?php } else { ?> <div id=”map-canvas”></div> <?php } get_footer(); And functions.php like this: add_filter(‘query_vars’, ‘parameter_queryvars’ ); … Read more
You’ll have to prepare your own custom function instead of wp_link_pages to use in single.php file of your template. Here’s the custom function my_wp_link_pages proposal (contains original wp_link_pages code with commented out lines): function my_wp_link_pages($args=””) { $defaults = array( ‘before’ => ‘<p>’ . __(‘Pages:’), ‘after’ => ‘</p>’, ‘link_before’ => ”, ‘link_after’ => ”, /*’next_or_number’ => … Read more