Different body image backgrounds on different pages, posts and categories

You need to add the classes for the corresponding cases. For pages/posts: $css = “body.page-id-**post_id** { background-image: url(‘$bg_image’); }”; For categories: $css = “body.category-**category_id** { background-image: url(‘$bg_image’); }”; You can retrieve post_id with $post->ID. For the category you need to check whether the page is_archive() and to append the corresponding ID or category name.

Regex works in regexr, but not if I filter content [closed]

Per comments, it’s best to use single quoted strings for regexs in PHP (then only backslash and single quote are special), and only backslash as necessary, eg in this case $url_regex = ‘/href=”https://wordpress.stackexchange.com/questions/219419/(http”https):\/\/.+?”https://wordpress.stackexchange.com/”; (leaving out the positive lookahead which isn’t needed here).

Search and Replace Script Loader in Head Only Works in Footer

Can you try this, it was what I tried to explain in my comment. Again, this is just a guess. function js_async_attr($tag){ // Add async to all remaining scripts return str_replace( ‘ src’, ‘ async=”async” src’, $tag ); } add_filter( ‘script_loader_tag’, ‘js_async_attr’); function remove_js_async_head(){ // function to add async to all scripts remove_filter( ‘script_loader_tag’, ‘js_async_attr’); … Read more

To make some div display for a longer time

Since WordPress 3.5, there are build in time constants to make thing easier for you. They are MINUTE_IN_SECONDS HOUR_IN_SECONDS DAY_IN_SECONDS WEEK_IN_SECONDS YEAR_IN_SECONDS You can probably do 30 DAY_IN_SECONDS for a 30 day period or 4 WEEK_IN_SECONDS for a 4 week period. Obviously, for a 2 month period you will do 60 DAY_IN_SECONDS

previous_post_link inside of a function?

previous_post_link() and next_post_link() should work inside the the_content filter. There is nothing wrong with your code except you must return the value inside the filter instead of print. Otherwise I believe post link should be there at the beginning of content. previous_post_link() and next_post_link() print the output so consider using get_previous_post_link() and get_next_post_link(). function prevnext( … Read more