Adding short codes from a page’s content on header and hiding the same from page’s content

This might work for you, trying to hook early to the_content filter to strip the shortcode tag from it: add_filter(‘the_content’, ‘ad_filter_the_content’,1,1); function ad_filter_the_content($content) { // specify page id or array of page ids to include if (is_page(5)) { return str_replace(‘[orbit-slider category=”test”]’, ”, $content); } return $content; }

Content only on last page, if the page has pagination

Instead of using the global variables directly, here’s a way to use the content_pagination filter to add custom HTML to the last content page: /** * Append HTML to the last content page, if it’s paginated */ add_filter( ‘content_pagination’, function( $pages ) { if( count( $pages ) > 1 ) $pages[count($pages)-1] .= ‘<div>MY HTML HERE!</div>’; … Read more

Database sync between local and production

If you have databases reachable from the outside ie: mysql1.example.com you can work on a local development environment connected to that the whole time. I just found a nice thing to put in wp-config.php to be able to change the host depending on your environment $host = $_SERVER[‘HTTP_HOST’]; define( ‘WP_HOME’, ‘http://’ . $host ); define( … Read more

Which template holds what to display when search returns nothing

get_template_part( ‘content’, ‘none’ ); will look for: content-none.php content.php Twenty Thirteen does have content-none.php. In general this is organized in such way to support dynamic lookups where first two-part template might or might not exist and fallback to more generic template, if necessary.

Change Content for Specific Page

Your function is signup but you’re hooking check_for_signup. You’re also trying to apply the_content filters from within a function that’s hooked to the_content: function wpse_225562_replace_for_signup( $content ) { if ( strcmp( ‘signup_slug’, get_post_field( ‘post_name’ ) ) === 0 ) { $content=”Sign up, bitch.”; } return $content; } add_filter( ‘the_content’, ‘wpse_225562_replace_for_signup’ ); Here we are simply … Read more

Gutenberg First Block on Page Conditional?

Here’s a solution I’ve come up with, that works with WordPress 5.4 and ACF Pro 5.8.9. First you need this function somewhere in functions.php: /** * Get ID of the first ACF block on the page */ function sg_get_first_block_id() { $post = get_post(); if(has_blocks($post->post_content)) { $blocks = parse_blocks($post->post_content); $first_block_attrs = $blocks[0][‘attrs’]; if(array_key_exists(‘id’, $first_block_attrs)) { return … Read more

Adding content to sidebars

Add a meta box to the post editor, similar to the excerpt meta box, and get the content of the meta box in your sidebar. If you want to reuse the same text on different pages create a custom post type sidenotes and add a meta box with a select field to let the author … Read more