Tag Info

Hot answers tagged

3

I want to suggest you another approach. You can set a meta when you saving a post if its content is less than 140 chars, so then you can simply runs a simple meta query. add_action( 'save_post_post', function( $id, $post ) { if ( $post->post_status !== 'publish' ) return; if ( strlen( $post->post_content <= 140 ) ) { update_post_meta( $id, ...


3

You have a lot of PHP tag spam, e.g.: ?><?php This is bad, confusing, makes your code difficult to read, and a waste of your time to type. It's the difficulty reading your code that has lead to your problem, including the lack of indentation. These are important, and any good editor will do them for you effortlessly. If we remove the PHP tag spam, ...


2

You should wrap your enqueue/register function in your conditional, not your add_action() You can try something like this using the is_404() conditional check function enqueue_404_script() { if(is_404()) { //do what you need to do } } add_action( 'wp_enqueue_scripts', 'enqueue_404_script' );


2

Yes, you could try this - foreach( $create_pages as $new_page ){ $content = "Default ". strtolower($new_page) ." page content"; $add_pages = array( 'post_title' => $new_page, 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'page' ); $page_id = wp_insert_post($add_pages); } ...


2

I am not calling it inside of a hook but just straight away as the first thing in a MU plugin. At that point all the info you are requesting won't be available. That's running before any hook and before WP is fully loaded. Use a hook like wp_loaded, admin_init, after_setup_theme ... whatever serves your purpose best.


1

Since WP 3.3 you can use wp_enqueue_*() after wp_head, and enqueued scripts and styles (if not already added to the head of the page) would be loaded in the footer. In short just call wp_enqueue_script() / wp_enqueue_style() in your shortcode callback: add_shortcode( 'my_shortcode', 'my_shortcode_callback' ); function my_shortcode_callback(){ ...


1

I can't help but think I am missing something but what seems like the obvious answer is to alter your $create_pages array: $create_pages = array( 'one' => 'content for one', 'two' => 'content for two', 'three' => 'content for three' ); foreach ($create_pages as $title => $content) { $add_pages = array( 'post_title' => ...


1

You need to add your function in the template_redirect hook. You need to first wait for wordpress to finish loading pages before you can add your hook to remove wpautop, otherwise your hook will simply get run over. So your funtion will look like this function pietergoosen_remove_wpautop() { if ( is_page ( 'services' ) ) { remove_filter( 'the_content', ...


1

The appropriately named get_children() should be what you want. if ( have_posts() ) { while ( $loop->have_posts() ) { $loop->the_post(); $args = array( 'post_parent' => get_the_ID(), // the ID from your loop 'post_type' => 'page', 'posts_per_page' => 1, // you only need to know if you have children so one is ...


1

Before starting answer I have to say that regarding this topic css and js are not the same. Reason is simple: while adding js to the body of the page (in footer) is a common and valid way to act, css need to be in the <head> section of the page: even if majority of browsers can proper render css in page boy, it is not valid HTML code. When a ...


1

The reason why your check didn’t work is because is_singular() checks for post types, not for post IDs. is_singular( 'product' ) checks if the current post is of the type product, nothing else. The comparison 2295 === get_the_ID() does exactly what you need.


1

I'd encourage you to take one step further back and avoid using URLs to determine theme at all. (And FYI, what you're describing are subfolders, not subdomains which would be red.example.com.) The reason not to do this is to avoid duplicate content issues with search engines. Technically, you could work around them, but it can also be confusing to visitors ...



Only top voted, non community-wiki answers of a minimum length are eligible