Activate different theme for temporary preview

You can Detect Server Remote Address and if it matches with your IP then you can use different theme following way. function wp_set_preview_theme( $current_theme ) { if ( ‘YOUR_IP_ADDRESS’ === $_SERVER[‘REMOTE_ADDR’] ){ // Use your preview theme instead return ‘THEME_YOU_WANT_TO_USE’; } else { // Otherwise, keep the current theme return $current_theme; } } add_filter( ‘stylesheet’, … Read more

Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes)?

The problem was the max memory limit. I had defined in config.php define(‘WP_MEMORY_LIMIT’, ‘512M’); But this was not working for me. But then I see , I need to define this define( ‘WP_MAX_MEMORY_LIMIT’ , ‘512M’ ); also in config.php. Now custom property type is working for me. Now I can edit this post type.

“wp_enqueue_style();” don’t load new edited style

Another solution is to use filemtime for the cachebusting, so that the last modified timestamp is used as the querystring variable. This has the advantage that of still using the browser cache, and yet, a new file is served when the file is actually changed because the querystring changes. eg. $lastmodtime= filemtime(get_stylesheet_directory().’/style.css’); wp_enqueue_style(‘whatever’, get_stylesheet_uri(), array(), … Read more

How to Remove Parents Category Permalink from Posts

With either str_replace or preg_replace, without either some naming conventions on the user end or some strong work in the method’s directives (linked, you can read about patterns here, ), you’re going to run into issues with the House | My House | New House scenarios; especially once you’re dealing with slugs, and if those … Read more

How to return a string that has a variable inside in a shortcode?

When you want to return a data combined with a string, you can use one of the following methods: Either open and close the string using ‘: return ‘<span class=”class2″ id=”class3-‘ . $random . ‘”> </span>’; Or use the double quote: return “<span class=”class2″ id=’class3-{$random}’> </span>”; You can simply use $random without the {} curly … Read more

Display certain amount of posts on taxonomy archive page

Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates? (Yes I know I also make queries in my templates but wanted to help out before leaving office) function wpse214084_max_post_queries( $query ) { if(is_tax(‘genre’)){ // change genre into your … Read more

WordPress Customizer: How can you have multiple active callbacks on one control?

You can create a third active callback function that just references the two existing ones, for example via an anonymous function (PHP≥5.3): // About Block Button Text $wp_customize->add_setting( ‘about_block_button_text’, array( ‘default’ => __( ‘Read More’, ‘my_theme_name’ ) ) ); $wp_customize->add_control( ‘about_block_button_text’, array( ‘label’ => __( ‘About Button Text’, ‘my_theme_name’ ), ‘type’ => ‘text’, ‘section’ => … Read more

Correct use of curly braces vs alternative synax

As in many things wordpress, inertia has a lot to do with why things are done in specific way. Early core themes were written using those constructs and later developers copied them because they either did not know better or thought there was some non obvious reason to prefer them. As @Howdy_McGee said, it is … Read more

Correct way to make static pages editable in wordpress

This is a little bit of a “finding the right balance” kind of question. You are struggling with the balance that all custom theme developers must work with. At the one end of the spectrum your content area just spits out the_content() and all of the content formatting and control is up to the user … Read more