Add field to user meta table in database when link is clicked

Personally, I would store the post IDs (as opposed to URLs). Something like: function wpse_143643_add_user_bookmark() { if ( ! empty( $_GET[‘bookmark’] ) && is_singular() && is_user_logged_in() ) { if ( ! $bookmarks = get_user_meta( $user_id = get_current_user_id(), ‘bookmarks’, true ) ) $bookmarks = array(); $bookmarks[] = get_queried_object_id(); $bookmarks = array_unique( $bookmarks ); update_user_meta( $user_id, ‘bookmarks’, … Read more

Post list display year wise

I don’t like recommending a plugin, but this plugin does exactly what you need, and it is the easiest way to go. Just before I start, I would like to state that I don’t have any affiliation regarding the plugin or its authors, nor am I marketing or trying to market the plugin in any … Read more

Post type no single page

First, before you start, just reflush your permalinks. It is sometimes strange why the Template Hierarchy fails. You code checks out, and should in theory work. Everything checks out, and to make sure, I tested it on my side. You can use this work around to “force” wordpress to use a template. Here we would … Read more

Create a list of posts with topic headdings

OK I got it working. Not sure if it is the best way but I thought I would add a reply anyway. Set up the information needed for the custom loop using $args = array As described in http://codex.wordpress.org/Class_Reference/WP_Query $args = array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘wpcf-topic’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘posts_per_page’ … Read more

is_page() and is_page_template() not being differentiated

Your code will never get to the is_page_template() if statement because is_page_template() can only be true when is_page() is also true. It also looks like you’ve got some muddled elseif syntax (I think that’s what you want?) and some generally inefficient code that repeats a lot. I’d do this: <?php if( is_page_template(‘right-sidebar.php’) ) { // … Read more