Strange behavior on WP_query
My fault: missing ‘posts_per_page’ => -1, in the query
My fault: missing ‘posts_per_page’ => -1, in the query
Yes. From your description, it appears that all of the requirements to automate this process are in place. The data is provided via XML which can be parsed with PHP to the necessary title, body, meta components. [search] WordPress supports programmatic post insert/delete/edit functions so that part is fairly simple. [WP Codex] Now you just … Read more
To strip HTML tags and shortcodes, use a combination of PHP’s strip_tags ( http://php.net/manual/en/function.strip-tags.php ) and WordPress’s strip_shortcodes ( https://codex.wordpress.org/Function_Reference/strip_shortcodes ) $meta_des = strip_shortcodes( strip_tag( $des ) );
Try this instead: remove_filter (‘the_content’, ‘wpautop’); You can also look at your page.php or template file and investigate which elements/tags are being used. Hope this helps!
This is because the value of meta key is inside the if clause and is not set for the else. try else { $key = ‘save-author-to-book’; delete_post_meta( $post_id, $key, $meta_value=””); // break; }
Well first off get_current_screen only works in admin area but even in admin can cause problems on some page. Use the $pagenow global variable instead. So now if you want to hide media not uploaded by a contributor this is how I would do it. // Prevents user to see all uploads, only theirs add_action(‘pre_get_posts’,’wpse_users_own_attachments’); … Read more
There are several ways to do this. Here’s an easy one. Let’s say you want to mix 9 ‘daily’ posts and 3 ‘quotes’. First you would have to get those posts: $dailies = get_posts(array(‘posts_per_page’ => 9, ‘post_type’ => ‘daily’)) $quotes = get_posts(array(‘posts_per_page’ => 3, ‘post_type’ => ‘quote’)) Next you would loop through them like this: … Read more
First of all return is used in PHP to return a value from a function. If you want to display something you need echo. Second, no excerpt is displayed in the lines you are pointing to. The excerpt is retrieved and then stored in a variable $myExcerpt. If you want to add … to the … Read more
Figured it out as per this answer. You cannot put any loop or control structure if/else as array value or anywhere within array(). Example $contact_list = []; $contact_list[‘url’] = ‘Website’; foreach ( wp_get_user_contact_methods() as $value => $label ) { $contact_list[$value] = $label; } $settings_fields = array( // Parent array ‘dsbl_basics’ => array( // Child array … Read more
If I understand correctly you wish to retrieve your meta data from the database? Try looking at this WP function: https://developer.wordpress.org/reference/functions/get_metadata/ This will allow you to get the meta data you require dependent on the type of data you want to get, such as post meta data or page meta data etc. An additional read … Read more