Duplicating Table of Contents for Paginated Post

You split post content into multiple pages with <!–nextpage–>, so you can use $page_number = get_query_var( ‘page’ ) to get current page number and global variable $numpages to get the number of pages in current post. Displaying table of content: global $numpages; $post_link = get_permalink(); $page_number = get_query_var( ‘page’ ); $toc = [ 1=>’Introduction’, ‘I2C … Read more

Conditionally hide or show woocommerce product variation in fontend by custom field

I ultimately solved this by manipulating the $options array. See full code below for conditionally hiding a product variation by a custom field, and display variations as radio buttons. Solution marked with comments /** * Convert WooCommerce variation dropdown to radio buttons. * * @param string $html Original dropdown html. * @param array $args Arguments. … Read more

Change content of page in child theme using plugin

It depends on where you want to put the ‘hello’ thing. For instance, you could use the_content filter to put it before or after the content: function wp_add_to_the_content($content) { $content=”Text before the content.” . $content . ‘Text after the content’; return $content add_filter(‘the_content’, ‘wp_add_to_the_content’,10,1); You’d need to add any CSS and other tags to format … Read more

Conditional PNG Overlay in Custom Post Type Loop Depending on Post Type

You can do: if( ‘video’ == $post->post_type ) $play_button = ‘/images/btn-play.png’; elseif( ‘slideshow’ == $post->post_type ) $play_button = ‘/images/btn-ss.png’; Then render the button with: <img src=”https://wordpress.stackexchange.com/questions/4052/<?php echo get_bloginfo(“template_directory’) . $play_button; ?>” class=”play” /> Hope that helps!

Can I create a loop with multiple post types and specify different $args for each post type?

Can I create a loop with multiple post types and specify different $args for each post type? Simply put no… you can’t have a single query instance with three differing sets of arguments. The reason why is pretty simple, the query class will only take one array of arguments per instance. If you want differing … Read more

wordpress is_page() problem

You probably want to drop the conditional during init. You are just registering the script here, not enqueueing it. Once registered, you should be able to call the script later in the action sequence. Please try something like this: function myplugin_css() { if ( is_page( ‘myinfopage’ ) ) { wp_enqueue_script( ‘RGraph’ ); } } add_action( … Read more

Conditional custom field query

I found this: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query I have modified the date to retrieve the last 15 days. It’s untested, but should work. $expireDays=”15″; $querystr = ” SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”post” AND $wpdb->posts.post_date >= ( CURDATE() – INTERVAL $expireDays DAY ) ORDER BY $wpdb->posts.post_date DESC “; $pageposts = $wpdb->get_results($querystr, … Read more

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