Automatically add Link Images to Posts in WordPress if has not linked before or has specified class

I use this code to Automatically add Link Images to Posts in WordPress.

function wpguy_linked_image($  content){ if (is_single() === TRUE){ $  searchfor = '/(<img[^>]*\/>)/';   $  replacewith = '<a target="_blank" href="'.get_permalink().'">$  1</a>'; { $  content = preg_replace($  searchfor, $  replacewith, $  content); } } return $  content; } add_filter('the_content', 'wpguy_linked_image'); 

How can I add a condition that if the img tags are already linked or have class="no link me" , they will be excluded from linking?

Will URL parameters affect SEO of blog posts

I have written some simple js/php that adds WordPress taxonomies and categories of posts to the urls of blog posts so that we can search in google analytics which posts with matching taxonomies are performing better.

Before I put this live though I would like to know how and if this will effect ranking of those posts. I have tried online but so far i am struggling to find an answer.

example of the URL pre and post URL params


Added information thanks to Stephen : The parameters are always consistent. I am doing a pushState refresh to add the url parameters so the page refreshes with the parameters. The posts will always have the parameters. The canonical tag is the original url.

How to arrange custom posts in the backend/admin by custom taxonomy

I’ve got a plug-in that uses a custom post type which allows custom taxonomies. The post type is employees and the the custom taxonomy is company. What I want to do is group all the employees(custom post) to the companies they are apart of, they can only be assign to one company. Is this possible? I can do easily front end through a template. I can’t work out how to create a sorting ability in the admin par the date.

Add a functionality to quickly filter custom posts in Admin Area

I am creating a website for a doggie rescue, basically configuring the backend so they can manage dogs, volunteers, etc.

The legacy system had a feature where the user could start typing into an input field and all matching results would be displayed as you typed, most likely making ajax calls.

They would like to have this feature in WordPress. I tried using Admin Columns but you have to create the filter, modify the value and then click the Filter button and wait for it to load the results. I want to avoid the "click filter button and wait for page to come back with results" part.

One of the CPT that I am creating, volunteers, apparently has 40K records, and they would like to filter through them by using this "filter as you type" idea.

Is this possible from WPAdmin? I mean, adding a text input field that would filter all the posts using AJAX?


Shortcode not working in Jetpack Top Posts & Pages widget

I’ve added [year] shortcode to some of my posts’ titles.

I used this in functions.php to enable this shortcode:

add_shortcode( 'year' , 'current_year' ); function current_year() {     $  year = date("Y");     return "$  year"; } 

I then added this too to enable shortcodes in widgets:

add_filter( 'widget_text', 'do_shortcode' ); 

But the shortcode doesn’t work in the post titles list shown by Top Posts & Pages widget by Jetpack.

How do I fix it?

Display Posts that fit a certain criteria on Category pages

I wish to display posts that fit a certain criteria on a category page. Something like a search filter applied, to several such category pages.

For example, to display all movies by Chris Pratt that grossed over 10 million dollars. Or All movies with Chris Pratt and Zoe Saldana, etc.

How / where would I have to look for a good tutorial on how to do the same?

Would it go into the realms of custom fields with custom taxonomies? Please advise if possible.

How to sort wordpress posts already selected by WP_QUERY

English is not my first language, sorry 🙂

I need differend per paginate page sorting.

For exemple, I created the loop:

 $  qargs = array(                     'posts_per_page' => 15,                     'no_found_rows'  => true,                     'order' => 'DESC',                     'post_type' => 'post',                     'suppress_filters' => false,                     'orderby' => 'post_views', // here I order my posts by views                     'fields' => '',                     'date_query' => array(                         array(                             'after'     => '-7 days',                             'column' => 'post_date',                         ),                     ), posts_query = new WP_Query( $  qargs ); 

And now I can display 15 selected posts sorted by views like this:

if ( $  posts_query->have_posts() ): ?>                 while ( $  posts_query->have_posts() ):                     $  posts_query->the_post(); ....... 

But I need to select 15 most viewed posts and after that to sort them by date.

Is it possible?

Thank you!

WordPress front-end user create list of posts wether logged in or not

I am in need of some advice/nudging in the right direction to achieve the following:

Users visiting the WordPress site will be presented with a list of artist profiles (these are set up as a custom post type).

The User will then be able to add/save the post to either a new list or add to an existing list called ‘User Projects’.

If they’re not logged in, they would be able to create a temporary list, with the ability to login and save it.

I have ACF Pro installed, and at the moment I’m using the ‘Post Object’ field to link the posts in the WP Admin, but I now need this to work on the front-end and without the need to be logged in to begin with.

Ideally this would all be done with an ajax button, allowing for a smooth user experience.

All help greatly appreciated.


Imported posts and terms but terms not appearing on the frontend

I created a giant import that grabbed both taxonomy terms and posts from a different application. To import the terms I used wp_set_post_terms( $ post_id, $ term_ids, 'my_taxonomy' ); which works because I see them on the edit screen for each post.

However, when I go on the frontend and look at my post the terms are empty. If I go back on the edit screen and just click on "Save" then they finally appear on the front end.

I have close to 2,000 records and doing this manually would be quite unwieldy and I can’t for the life of me figure out what happened! How do I force this update across the board programmatically?

I’ve tried using both clean_term_cache(); and clean_object_term_cache(); and it didn’t seem to make a difference. Maybe I’m calling these wrong but it’s not doing a thing as far as I can tell.

I’ve tried:

  • clean_term_cache
  • clean_object_term_cache
  • delete_option($ tax.’-slug_children’);
  • delete_option($ tax.’_children’);
  • clean_taxonomy_cache($ tax);
  • wp_cache_flush();