how to get and display logged in user’s recently read posts

For that you first need to SAVE when someone logged in reads a post. You can do this for instance within an action like get_header. add_action(‘get_header’,’save_single_posts_to_usermeta’); function save_single_posts_to_usermeta(){ if(is_single() && is_user_logged_in()){ $user_id = get_current_user_id(); $read_posts = get_user_meta($user_id,’_read_posts’,true); $most_recent_read_post = get_user_meta($user_id,’_most_recent_post’,true); if(!is_array($read_posts)){ $read_posts = array(); } if(!isset($read_posts[get_the_ID()]){ $read_posts[get_the_ID()] = 1; } else { $read_posts[get_the_ID()] = $read_posts[get_the_ID()]+1; … Read more

Most efficient way to get custom database records from 20 buttons and 20 tables?

I suppose the easiest way would be to have the action or other parameters in the button itself, i.e. <div class=”mybutton” data-action=”get_quote” data-type=”literary”>Get a literary quote</div> <div class=”mybutton” data-action=”get_quote” data-type=”political”>Get a political quote</div> data-foo=”bar” attributes can easily be accessed in jQuery with .data(“foo”), so you could change the jQuery around a bit to listen to … Read more

How to override a non pluggable and non hookable function in a WordPress parent theme?

to redefine the AJAX action, you can try that add_action(AE_Base::AJAX_PREFIX . “ae-profile-sync”, function () { $profile_action = $GLOBALS[“et_freelance”]->profile_action; // remove base action remove_action( AE_Base::AJAX_PREFIX . “ae-profile-sync” , [ $profile_action, “sync_post”, ] , 10 ); // add new AJAX action add_action( AE_Base::AJAX_PREFIX . “ae-profile-sync” , function () { // new code here } ); }, 1); … Read more

display most popular tags in two columns

In my opinion you are doing it so complicated. I would rather do a classic query and then through css it made into 2-column. function top_tags() { $tags = get_the_tags(); if($tags) { $output=”<h4>Top tags</h4> <ul class=”top_tags”>”; foreach($tags as $tag) $output .= ‘<li><a href=”‘.get_tag_link($tag->term_id).'” title=”‘.$tag->name.'”>’.$tag->name.'</a></li>’; $output .= ‘</ul>’; echo $output; } } and your css .top_tags … Read more

Print Dashboard menu name and link

Not sure what you are trying to accomplish precisely, since you don’t cover that part. Looking at the data I would guess you can filter out separators and such by checking for proper title: global $menu; foreach ( $menu as $group => $item ) { if ( ! empty( $item[0] ) ) { echo $item[0] … Read more

Automatically add author’s name to post_tag

Check get_the_author() (Note:This tag must be used within The Loop.) you code may be like this In functions.php: add_action( ‘save_post’, ‘add_authors_name’); function add_authors_name( $post_id ) { global $post; $post_author = $post->post_author; // returns the Author ID // get the author’s WP_User object so we can get the Author Name $post_author_obj = get_userdata( $post_author ); $post_author_name … Read more

Run Product Filter Javascript On Page Template

In WordPress, you should use wp_enqueue_script() to load JavaScript files, and wp_enqueue_style() to load CSS files, and the functions should be called using the wp_enqueue_scripts action hook. Additionally, the theme needs to call wp_head() (in header.php) and wp_footer(). And to enqueue a script only on specific pages, you would use a conditional tag like is_page() … Read more