How to modify the Loop from a plugin (instead of a theme)

for a simple meta query you can do this: function wpa_47150( &$query ) { if(!is_admin()){ set_query_var(‘meta_key’, ‘test_field’); set_query_var(‘meta_value’,’bacon’); } } add_action(‘pre_get_posts’,’wpa_47150′); i wasn’t sure it was going to work, but apparently you can set the whole meta_query object this way too function wpa_47150( &$query ) { if(!is_admin() && is_post_type_archive( ‘test_post_type’ )){ $metaq = ( array … Read more

WordPress, alternative single post template

You could set a url parameter to change the display so that the URL could be the same, then have your QR code do a pass-through to the desired page. Without knowing how the QR codes are setup and such, I can’t offer much more on high-level implementation than that. The way to switch the … Read more

How to hide plugin options for editors via functions.php

This should be easiest way, just add the line to wp-config.php, this will disable plugin and theme editor, both. define(‘DISALLOW_FILE_EDIT’,true); If you want to add codes into theme’s function, the code should work for you. function ra_block_tp_edit( $caps, $cap ) { if($cap == ‘edit_plugins’ ) $caps[] = ‘do_not_allow’; return $caps; } add_filter( ‘map_meta_cap’, ‘ra_block_tp_edit’, 10, … Read more

Settings options not showing up on Sub Menu page in WordPress plugin

If you check the arguments for add_menu_page, you’ll see that the fifth argument is your callback function. And, right now, there’s nothing in the mj_admin function. What you need to do is output your form in that function. <?php function mj_admin(){ ?> <h2>My Settings Page</h2> <form action=”options.php” method=”post”> <?php settings_fields( ‘mj-admin-settings’ ); do_settings_sections(‘mj-admin-settings’); submit_button(); ?> … Read more