Laxmana
  • Member for 8 years, 1 month
  • Last seen more than a month ago
1 answers
1 votes
13k views
Code to create a redirection after login?
Accepted answer
3 votes

You can use the login_redirect hook. function redirect_admin( $redirect_to, $request, $user ){ //is there a user to check? if ( isset( $user->roles ) && is_array( $user->roles ...

View answer
5 answers
16 votes
61k views
When moving a WP site, why does wp-admin redirect to old site?
0 votes

You have to change the Site address (URL) and WordPress address (URI) through admin panel before moving the site to another URL. In your case you can't do that to a live site, so you can try a tool ...

View answer
2 answers
0 votes
528 views
Proper Way to Load stylesheet on Condition
1 votes

From the docs: Registers the style if source provided (does NOT overwrite) and enqueues. That means that when you use wp_enqueue_style the css file will be registered and enqueued for output. ...

View answer
7 answers
15 votes
24k views
Attributing a version number to a child theme's main stylesheet
17 votes

I think the best way to do this is to leave the child theme stylesheet (style.css) empty with only the necessary comments (like theme name, description etc, so can wordpress recognize your theme) and ...

View answer
1 answers
2 votes
56 views
Could a higher number of registered image sizes affect performance?
Accepted answer
1 votes

Depends. One argument could be that if the requested page use all sizes then there will be a lot of image calls (slower response, bandwidth etc) but you can bypass that i.e. by loading images with JS. ...

View answer
1 answers
0 votes
78 views
How can i show post_class() within output loop?
2 votes

You should use get_post_class() From Codex: get_post_class() is not simply a non-echoing alternative to post_class(). get_post_class() does not return a string, but an array that must be ...

View answer
1 answers
0 votes
3k views
Set featured image to archive.php
Accepted answer
3 votes

In my opinion the right way to do this is to create theme options. Create a field asking the desired image for the clients post type archive.

View answer
2 answers
1 votes
2k views
How am I able to get the value out of cookie array when I push a button?
3 votes

You need to put the id of each item inside form to indicate the item that will be deleted. <?php $all_favorites= unserialize($_COOKIE['favorites']); echo '<table>'; foreach($all_favorites ...

View answer
1 answers
3 votes
6k views
WP API : date_query parameter
Accepted answer
3 votes

As of WP >= 4.7 filter[] is not supported and have been removed. Also WP REST API Plugin became part of WordPress Core. According docs your link should be: https://wptest.enguerranweiss.com/wp-json/...

View answer
1 answers
1 votes
1k views
Replacing mysql_escape_string in a custom plugin when moving to PHP7
0 votes

You don't need to sanitize the variables that are passed to wp_update_post() because wp_update_post() after some checks pass the data to wp_insert_post() and wp_insert_post() calls sanitize_post(), ...

View answer
1 answers
0 votes
1k views
AJAX call inside plugin class not triggering
Accepted answer
3 votes

The ajax_url should be admin_url( 'admin-ajax.php' ) and not plugins_url( 'plugin.php', __FILE__ ) when you localize your js variables.

View answer
1 answers
1 votes
329 views
How do you use WP slugs for PDF files / media?
1 votes

In my opinion it is best to add an endpoint of the form mysite.com/pdf/<id> or something similar to your like. That way you avoiding attaching the attachments to posts/pages or create a page for ...

View answer
1 answers
1 votes
675 views
WordPress search results with Ajax, get_post_type() not working
Accepted answer
0 votes

$_GET['s'] will not work for two reason. Firstly you make a POST request and not a GET request and secondly there is no variable with name s in your request. When executing an AJAX request through wp-...

View answer
1 answers
0 votes
419 views
WP search exclude last letter from string
0 votes

You can use the get_search_query filter. function mySearchFunction($search_term){ $search_term = substr($search_term, 0, -1); return $search_term; } add_filter('get_search_query','...

View answer
2 answers
2 votes
5k views
Order and group posts by acf by month and year
6 votes

When you query the posts with orderby argument as a event_date (it could be any field with date format) the posts are ordered by date, desc or asc. So the only thing you have to do afterwards is to ...

View answer
1 answers
0 votes
2k views
Pagination not working with custom post type
2 votes

From WordPress Codex: Add the $max_pages parameter to the next_posts_link() function when querying the loop with WP_Query. To get the total amount of pages you can use the 'max_num_pages' ...

View answer
2 answers
1 votes
3k views
term_link() filter or rewrite and howto?
Accepted answer
1 votes

I know I am not answering exactly your question but in my opinion it is best to do it manually without messing with rewrite rules and filters. That way you keep also the default URL structure for ...

View answer
2 answers
1 votes
45 views
Creating a Custom Post Type
Accepted answer
0 votes

You have to flush the rewrite rules of WordPress. You can do it either by going to Permalink Settings and click save or by using flush_rewrite_rules That's happens because WordPress doesn't know the ...

View answer
1 answers
1 votes
1k views
API Rest Custom Post Type doesn't return all data
Accepted answer
0 votes

By default WordPress return 10 posts per pages. To change the number of posts per page you should query http://www.mysite.it/wp-json/wp/v2/portfolio/?per_page=71. The max is 100 posts per request.

View answer
2 answers
2 votes
605 views
How to get Custom Post ID by adding filter to child theme's function
0 votes

For custom post types there are the corresponding filters manage_{$post_type}_posts_columns and manage_{$post_type}_posts_custom_column where {$post_type} is your custom post name ($post_type variable ...

View answer
4 answers
0 votes
78 views
Environment independent way to link to certain pages on frontend
2 votes

I think the best way is to create Theme Options and let the administrator decide which page is each one, with a dropdown for example. This way you can get the selected page no matter the environment.

View answer
1 answers
1 votes
67 views
Pulling Data from CSV vs. pulling data from database
Accepted answer
0 votes

Reading, searching and closing a file every time the page is loaded is highly time consuming. Database systems are highly optimized for reading and writing huge amount of records, querying data, ...

View answer
2 answers
2 votes
81 views
Show link to add menu
1 votes

You can get the url like this: admin_url('nav-menus.php') I search a lot to find a better way, through WordPress API, but I couldn't find a proper function. I took a look into WordPress core and they ...

View answer
1 answers
2 votes
1k views
Set media metadata (i.e. "dimensions" field) on SVG file after extracting it with a filter
Accepted answer
5 votes

The wp_update_attachment_metadata filter fires every time you upload an image through media library (specifically every time wp_update_attachment_metadata function is being called). So when an svg ...

View answer
3 answers
0 votes
870 views
Error [Column 'post_title' cannot be null] when title is disabled for Custom post type
0 votes

I would remove the wys_slide_title filter and move the logic inside save_post action. Haven't test it but is should work. add_action('save_post', 'wys_slides_save_details'); function ...

View answer
5 answers
0 votes
3k views
how can i allow users to view their own pending posts in a front-end page
1 votes

According to Wordpress Codex is a post status that awaits a user with the publish_posts capability (typically a user assigned the Editor role) to publish. (pending) In other words, a post that is ...

View answer
1 answers
1 votes
2k views
Simple ajax call not working in wordpress plugin
1 votes

You have to put the name of your wp ajax action in your data when you do the ajax call. I assume the ajax url is correct. jQuery( document ).ready(function(){ //alert("Jquery Loaded"); jQuery("#...

View answer
2 answers
0 votes
133 views
Conditional: IF current author's custom post has a post thumbnail
0 votes

The condition in my answer says that if the user is logged in and if the current user is the user that posted the current post and if that post has a featured image then do something. if(...

View answer
2 answers
0 votes
252 views
How to show taxonomy in WordPress shortcode
0 votes

I assume that you have a custom post type movie and a registered taxonomy to this post called genre. The second argument of the_terms function is wrong. It has to be a string not an array: ...

View answer
1 answers
1 votes
402 views
Finding the URL to be used to check if plugin is installed with a theme
0 votes

This are not url's. They are paths. So disqus-comment-system is the folder of the plugin and disqus.php the "init" php file. Every plugin has more or less the same structure. Install your desired ...

View answer