Articles of functions

post meta data clearing on autosave

For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here: Custom field/meta populated by dropdown of existing posts? I am running into a problem however when wordpress auto saves itself, it clears […]

PHP Deprecated: WP_RSSjb has a deprecated constructor

I get messages in the debug.log for PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WP_RSSjb has a deprecated constructor in /home/dccomp/competitions.com/wp-content/plugins/rss-just-better/RSS-just-better.php on line 57. How can I modify this? The line is class WP_RSSjb extends WP_Widget { /** * Widget setup. */ […]

Run functions only in the admin area?

I’d like this code to only run inside the admin area as it is resorting the items on the public side admin bar too. /* Reorder Admin Menu to put “Pages” at the top */ function menu_order_filter($menu) { $content_menu = array(‘edit.php?post_type=page’); array_splice($menu, 2, 0, $content_menu); return array_unique($menu); } add_filter(‘custom_menu_order’, create_function(”, ‘return true;’)); add_filter(‘menu_order’, ‘menu_order_filter’);

Add a plugin before main container

If I have a plugin that prints (simply) “Hello World”, and I want it be outside of the main container, so, like this: <h1>Hello world!</h1> <div id=”content”> . . . </div> Instead of: <div id=”content”> <h1>Hello world!</h1> . . . </div> How can I make that work? I created a child-theme and I don’t want […]

Add confirmation popup on “Move to Trash”

I want to open javascript message “Are you sure you want to move the post to trash?”when we clicks on “Move to Trash” link in Publish box. and when we click to OK the post go to trash or cancel to go back to the post. I found this code on previous question. It’s open […]

Dynamically Override Fancy Title

I’m trying to override Fancy Title created using The7 Theme. The7 Titles are generate from this function: function presscore_get_page_title() { $title = ”; if ( is_page() || is_single() ) { $title = get_the_title(); } else if ( is_search() ) { $title = sprintf( __( ‘Search Results for: %s’, ‘the7mk2’ ), ‘<span>’ . get_search_query() . ‘</span>’ […]

Passing arguments to my function with do_action and add_action is not working

I have this code and the $var1 arrives empty to my function i dont know why, i’ve tested declaring the variable inside the function and it does work but when i try to declare it outside the function and pass it as a parameter with the do_action it doesn’t work, any insights on this ? […]

Use a function to update post meta based on other post meta

No idea how to title this so feel free to edit. I set out to create a “hotness” for my posts and to do this I used the $ratings_score which is stored as post_meta as a number +/- and the days ago of the post which I trimmed down to just the days. I divided […]

Include a php file from functions.php only to homepage

I’m re-developing a wordpress theme using sage them framework. I have this array in functions.php $sage_includes = [ ‘lib/assets.php’, // Scripts and stylesheets ‘lib/theme_options.php’, // Theme Options ‘lib/setup.php’, // Theme setup ‘lib/titles.php’, // Page titles ‘lib/wrapper.php’, // Theme wrapper class ‘lib/home_shortcodes.php’, // Homeapage Shortcodes ‘lib/shortcodes.php’ // Old Theme Shortcodes ]; which is loaded below foreach […]

Is there a wordpress function that I can use to retrieve the current page that is loaded?

Suppose that I create a page in the admin section (under ‘Pages’) and I have permalinks turned on and this pages slug is ‘my-new-page’, then is there a WordPress function that will work outside the (blog) Loop that I can use in that page’s template on my theme that will retrieve that page’s permalink?