Alexander Holsgrove
  • Member for 7 years, 9 months
  • Last seen this week
1 answers
votes
223 views
How to display warning on post editor when trying to add new term to custom taxonomy?
Accepted answer
7 votes

Whilst this doesn't show a warning as you are asking for, you could always hide the "add new" link using the admin_head action: function yourprefix_admin_head() { echo '<style> #language-...

View answer
1 answers
votes
2k views
Using Advanced Custom Field (ACF) to insert meta description on each page
Accepted answer
6 votes

As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below: <?php $meta_description = get_field('meta_description', ...

View answer
2 answers
vote
2k views
Create Pages from Database
3 votes

There seems little point in creating a new post entry for each of your products if your table of products already has all of the information you wish to display. Your best bet is to create a single ...

View answer
4 answers
vote
2k views
How to add css class to a specific set of images?
Accepted answer
3 votes

You can use the get_image_tag_class filter which passes the attachment ID as an argument: apply_filters('get_image_tag_class', string $class, int $id, string $align, string|array $size) So you can ...

View answer
2 answers
votes
1k views
get_terms with posts that have a different taxonomy with term x
3 votes

You could use the tax_query argument, for example: 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'tax1', 'field' => 'slug', 'terms' ...

View answer
1 answers
votes
2k views
Uninstall WP-CLI
Accepted answer
3 votes

You can remove the wp-cli.phar file (and also the .wp-cli directory). I don't think there is an installation as such for you to un-install since typically you just download and move the wp-cli script ...

View answer
1 answers
vote
5k views
How to add pagination to a single post
Accepted answer
3 votes

Forgive me for answering my own question, but this post gave me the answer I needed: WP_Query Pagination on single-custom.php I had to take a copy of the original wp_query $original_query = $...

View answer
2 answers
votes
67 views
Load template file without a post type
Accepted answer
2 votes

You could setup a custom rewrite rule using add_rewrite_rule and send these requests to a custom page. Your URL structure could be /index-page/single-event-slug The rule would point all of the single ...

View answer
2 answers
vote
5k views
How to change / delete product short description in Woocommerce
2 votes

You should have the $product global available to you, which lets you call set_short_description and then save to store the changes: $product->set_short_description('some description'); $product-&...

View answer
1 answers
votes
15 views
Inserting post content into pages when using custom taxonomies
Accepted answer
2 votes

That code never outputs anything to the page: <?php if(has_term('ART', 'product_relevance')): $my_post = get_post(927); if(isset($my_post->post_content)): ?> <div class="row"&...

View answer
1 answers
votes
125 views
Shortcode from a function not working
Accepted answer
2 votes

If you refer to the documentation for add_shortcode, you need your function to return the content: function uniquetestfunction($attributes) { return '<div class="my_class">Test Element</...

View answer
1 answers
vote
1k views
"add_post_type_support" with Custom Post Type & ACF
Accepted answer
2 votes

You need to use filters to hook into manage_posts_columns and manage_posts_custom_column which will let you add the table heading and dates. The filters are slightly special as you need to include the ...

View answer
1 answers
vote
36 views
Pagination not applied on posts
Accepted answer
2 votes

The pagination isn't working correctly because it assumes you want to paginate all results. You are simply hiding pages, by which time it's too late to adjust the pagination. To fix this, you need to ...

View answer
1 answers
vote
452 views
How can sanitize $_FILES['haq_slider'] field
2 votes

You don't say where this code is running - for users or just for admins. Here are a few tips, taken heavily from this article on Wordfence. The first check you can run is current_user_can to see if ...

View answer
1 answers
votes
67 views
Jetpack CSS .screen-reader-text breaks mobile menu
2 votes

You can: Setup a child theme and override the screen-reader styles using a more specific CSS rule Setup a child theme and override the header / menu and remove that css class Try and see if there is ...

View answer
2 answers
votes
141 views
How to use selected WordPress functions?
2 votes

You may be able to have Wordpress push data to the session or to your custom PHP, rather than trying to load Wordpress each time you need to query some the user. I'm not sure what other functions you ...

View answer
1 answers
votes
227 views
How show categories in admin and get that selected to show posts in index
2 votes

You can use Advanced Custom Fields to add two fields where the admin can select a category. On your index page, you then check the two fields using get_field for which category you want to display. ...

View answer
1 answers
votes
97 views
How to use if statement in an array?
Accepted answer
2 votes

Try this Omer $fields = array( 'author' => '<div class="form-group"><input class="form-control" id="author" name="author" type="text" placeholder="Name '.( $req ? '*' : '' ) .'" ...

View answer
3 answers
votes
2k views
Rename existing old uploaded images containing accented French characters (not during upload)
2 votes

I presume you used a script to rename 1000+ images, so you could probably apply your same rules to a MySQL update query on the wp_postmeta and wp_posts tables using a REGEX or a series of REPLACE() ...

View answer
3 answers
votes
498 views
WordPress localhost site always redirect to live site
1 votes

Look in your wp_options database table for the siteurl and home options and check these are using your local URL. As Captain S commented, these can also be overridden in your wp-config: define('...

View answer
1 answers
votes
36 views
Check for malicious code?
1 votes

If you want to be certain your site is clean, you can either start with a fresh install of WordPress, all of your plugins and the theme. An alternative would be to use the WP CLI verify-checksums to ...

View answer
1 answers
votes
22 views
Can I add other Custom Taxonomy to my syntax (functions.php)
1 votes

I believe you can also pass an array to is_tax: if(is_tax(array('country', 'us_state', 'cities')) { return 0; } Give that a try, but otherwise what you have is fine.

View answer
1 answers
votes
498 views
Two URLs of one post is available
1 votes

In this case you want to set a canonical URL to tell search engines that the content is duplicated over more than one URL. The canonical URL is a <link> tag which appears in the <head> of ...

View answer
2 answers
votes
461 views
Should I create Custom Page Types?
1 votes

You've highlighted the issue of creating custom post types in a theme rather than in a plugin. If the user changes to a new theme then you cannot rely on any functionality in the theme you have ...

View answer
1 answers
votes
53 views
Clear out old images, any advice?
1 votes

I think you have already discovered the problem with a plugin approach. They will look for unlinked media (images not associated with a post) and remove those files. As you have said, you are using ...

View answer
1 answers
votes
32 views
Trying to create a log in system but getting error "Parse error: syntax error, unexpected 'else' (T_ELSE) "
1 votes

That code looks completely mangled. Try: if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { header("Location: ../signup.php?error=invalidmail&uid=" . $username); exit(); } Count up the if ...

View answer
1 answers
votes
126 views
Access post title from custom meta box on title change
Accepted answer
1 votes

The event listener you have added will only attach to the available .editor-post-title__input elements, and won't attach to any dynamically added elements. You are better to move the listener to the ...

View answer
3 answers
vote
1k views
How to create a php url redirection for nicer links
1 votes

You will need to use add_rewrite_rule to register a new URL, and then also create a new page & template to handle where to link off to. For example: add_action('init', function() { $page_id =...

View answer
1 answers
votes
599 views
Save user total active time after login in wordpress
1 votes

You will want to use either a serverside method, adding a function or hook each time the user loads a page. The first time you check, you can set a cookie or session variable containing a timestamp to ...

View answer
2 answers
votes
59 views
Coming soon page used instead of home page
Accepted answer
1 votes

It looks like your theme has some sort of maintenance mode - there is a CSS class on the <body> of elementor-maintenance-mode Have a look at the documentation here: https://docs.elementor.com/...

View answer