Dynamically Create Posts Via XML File

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

Escaping html for meta description

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 ) );

admin uploads pre_get_posts not working as expected

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

For each 3 posts, show a different post type

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

Add point on excerpt post

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

How to use foreach and if statement within array of arrays?

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

direct query to post_meta table

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