Trigger a php file on every post or page if a condition is met
Trigger a php file on every post or page if a condition is met
Trigger a php file on every post or page if a condition is met
If you only want to adjust the link of the lost password page, then there is a designated filter for that: function wpse_133647_custom_lost_password_page() { return home_url(‘/lost-password’); } // function wpse_133647_custom_lost_password_page add_filter(‘lostpassword_url’, ‘wpse_133647_custom_lost_password_page’);
new WP_Query(array(‘tag_slug__in’ => array(‘forrest-gump’, ‘forest-gump’, ‘questend’))); new WP_Query(‘tag=forrest+gump,forest+gump,questend’); should work too…
Admin-AJAX is not optimized for JSON. If you need your answer to be in JSON, use the REST-API instead. This API generates JSON response by default. All you have to do is to register a rest route, and access the URL: add_action( ‘rest_api_init’, function () { //Path to REST route and the callback function register_rest_route( … Read more
This is relatively easily done using the walker_nav_menu_start_el filter (without all that PHP tag spam): function nav_replace_wpse_189788($item_output, $item) { // var_dump($item_output, $item); if (‘Profile’ == $item->title) { global $my_profile; // no idea what this does? if (is_user_logged_in()) { return ‘<div class=”img” data-key=”profile”>’.get_avatar( get_current_user_id(), 64 ).'</div>’; } } return $item_output; } add_filter(‘walker_nav_menu_start_el’,’nav_replace_wpse_189788′,10,2); Note: I had to … Read more
You have this: <li><?php echo $retrieved_data->column_name;?></li> <li><?php echo $retrieved_data->another_column_name;?></li> <li><?php echo $retrieved_data->as_many_columns_as_you_have;?></li> Here, the code tries to output the data in the column_name column, but there is no column in the table by that name. Likewise, there is no another_column_name or as_many_columns_as_you_have columns in your table. We know that the query pulls in the data, … Read more
(Revised on March 25 2020 UTC) So in this revised answer, I’ll just begin with the code: Define the variables: (I intentionally included only the $args part) // define POSTed/submitted variables here like $paged, $display_count and $direction // define the offset/’direction’ stuff here // then define your $args array $args = array( ‘post_type’ => ‘product’, … Read more
In a shortcode you always need to return something. It’s also good practice to make your code very logical and readable. Here are a list of PHP Logical Operators: http://php.net/manual/en/language.operators.logical.php Complete List of WordPress Locale Codes: https://wpastra.com/docs/complete-list-wordpress-locale-codes/ Below an example as English as a backup/fallback language: function coupon_shortcode() { $logged_in = is_user_logged_in(); if (get_locale() == … Read more
Sounds like you need to do some regular expression on your post content. Which could be done for example like this: // get the post object $post = get_post( get_the_ID() ); // we need just the content $content = $post->post_content; // we need a expression to match things $regex = ‘/src=”https://wordpress.stackexchange.com/questions/162402/([^”]*)”https://wordpress.stackexchange.com/”; // we want all … Read more
We don’t have an explicit filter for the data array so here are two workarounds that you might give a try: Approach #1 – As meta data We can add attachment_id to the meta data for each playlist item, via the wp_get_attachment_metadata filter, but first we have to register it via the wp_get_attachment_id3_keys filter. Here’s … Read more