jas
  • Member for 6 years, 3 months
  • Last seen this week
  • India
5 answers
24 votes
50k views
Custom Post Type pages are "not found"
Accepted answer
30 votes

For fixing custom post not found please use below code in your functions.php: flush_rewrite_rules( false ); You should only do this as a temporary measure otherwise it will run on every page load. ...

View answer
1 answers
1 votes
92 views
How to get total number of shortcodes in the wordpress application?
5 votes

Create a new page in Wordpress theme and use below code : <?php global $shortcode_tags; echo '<pre>'; print_r($shortcode_tags); echo '</pre>'; ?> ...

View answer
3 answers
2 votes
5k views
Remove lost password form and URL
Accepted answer
5 votes

Hi Please try to use this in your functions.php it will redirect user to login form when user try to access lost password page: add_action('init','possibly_redirect'); function possibly_redirect(){ ...

View answer
2 answers
0 votes
4k views
Use wp_logout_url() in menu creation page
Accepted answer
5 votes

Add submenu with a custom link, /wp-login?action=logout, like the image below: Add code like below in functions.php: function wpa_remove_menu_item( $items, $menu, $args ) { if ( is_admin() || ! ...

View answer
1 answers
2 votes
85 views
Add video from youtube in post
Accepted answer
4 votes

This is overview how you can make it working: First with below code you can detect youtube URL for details Please read: $reg = preg_match('|^\s*(https?://[^\s"]+)\s*$|im', $post_id_63->...

View answer
6 answers
8 votes
16k views
What is the best php version to use with WordPress?
4 votes

To run WordPress we recommend your host supports: PHP version 5.6 or greater MySQL version 5.5 or greater Note: If you are in a legacy environment where you only have older PHP or MySQL versions, ...

View answer
2 answers
2 votes
3k views
Disable automatic oEmbed of a youtube url within the content
Accepted answer
4 votes

disable the oembed like below in functions.php : remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); Thanks!

View answer
3 answers
0 votes
4k views
Get category URL knowing it's id
Accepted answer
3 votes

If you have category ID you can create link to category like below : <a href="/index.php?cat=7">Category Title</a> For more details read from this link : https://codex.wordpress.org/...

View answer
2 answers
1 votes
419 views
Limit comments displayed on basis of user_id
3 votes

Hi Just need to make your function to get comments and then use your function output at required places. <?php get_comments( $args ); ?> <?php $args = array( 'user_id' => $...

View answer
1 answers
1 votes
2k views
Hide the wp-admin bar from dashboard
Accepted answer
2 votes

This might be not proper approach but this worked for me while testing. You can use these combinations to remove all links from Toolbar (admin-bar ) and then hide empty tool bar with css: function ...

View answer
1 answers
1 votes
706 views
How to disable formatting
Accepted answer
2 votes

Please use this code in your functions.php function tinymce_paste_as_text( $init ) { $init['paste_as_text'] = true; return $init; } add_filter('tiny_mce_before_init', '...

View answer
2 answers
1 votes
4k views
How to change post status from publish to draft using hook in wordpress?
2 votes

In your functions.php : add_action('publish_post', 'check_user_publish', 10, 2); function check_user_publish ($post_id, $post) { if($post_id == 1){ $query = array( 'ID' => $...

View answer
1 answers
1 votes
96 views
Always paste as a text in visual editor
Accepted answer
2 votes

function tinymce_paste_as_text( $init ) { $init['paste_as_text'] = true; return $init; } add_filter('tiny_mce_before_init', 'tinymce_paste_as_text'); For details please follow link : ...

View answer
1 answers
-1 votes
37 views
No exposure on search engines
2 votes

Please go to Settings > Reading or wp-admin/options-reading.php If it's not unchecked it will not allow search engines to reach. For further modification information related to robots you can use ...

View answer
4 answers
8 votes
37k views
Unable to locate WordPress Content directory (wp-content)
2 votes

Adding below code to wp-config.php file will solve your problem: if(is_admin()) { add_filter('filesystem_method', create_function('$a', 'return "direct";' )); define( 'FS_CHMOD_DIR', 0751 ); } ...

View answer
1 answers
-1 votes
917 views
changed front-page template gives 500 error
2 votes

It seems like you might have done some syntax error etc please add these lines to wp-config.php to check error If you have backup of your previous file, restore it to check error if any are there. ...

View answer
1 answers
0 votes
3k views
Insert shortcode between '<div>'
2 votes

just use &lt;?php echo do_shortcode('[YOUR_SHORT_CODE_HERE]');?&gt; For more information: Short-code in code file $cb_byline = '&lt;div class="cb-byline"&gt;' . $cb_author . $cb_date . $...

View answer
1 answers
0 votes
1k views
How can I get rid of the automatically generating <span> tags?
Accepted answer
1 votes

If you use a child theme, just add this function to your functions.php file: add_action( 'after_setup_theme', 'foobar_setup', 11 ); function foobar_setup() { global $editor_styles; $editor_styles ...

View answer
1 answers
0 votes
2k views
Add category into post permalink
Accepted answer
1 votes

Please go to Settings > Permalinks. Have a look at the Permalinks page for other possibilities. For You I think you need to use: /%category%/%postname% Hope this help! UPDATE : For additional ...

View answer
1 answers
0 votes
109 views
Changing the title of "<- back to" website in wp-login.php
1 votes

Please add below code to your functions.php to remove the &amp;larr; from the translated string: /** * Remove &amp;larr; from the '&amp;larr; Back to %s' translation */ add_action( 'login_init', ...

View answer
3 answers
2 votes
3k views
Exclude a specific tag from the get_the_tags list
Accepted answer
1 votes

$tags = get_the_tags( $post-&gt;ID ); $separator = ' '; $output = ''; if($tags){ echo '&lt;div class="entry-tags"&gt;'; echo "&lt;p&gt;&lt;span&gt;" . __('Tags', 'tracks') . "&lt;/span&gt;"; ...

View answer
2 answers
1 votes
2k views
Show archives by year from just one category
Accepted answer
1 votes

If I understand you question clearly that we just need to get post in that submenus from only cat id = 4 , this will make your archive.php to work only for cat id = 4 Please add below code to ...

View answer
1 answers
0 votes
1k views
Adding archive years to my menu
Accepted answer
1 votes

Hi Please follow below code do add dynamically year wise post under sub menu you want, I have added below code in functions.php add_filter( 'wp_nav_menu_objects', 'ravs_add_menu_parent_class' ); ...

View answer
1 answers
0 votes
3k views
call other shortcode in the email contactform7 send
1 votes

For sending in mails you can use below code: add_filter( 'wpcf7_special_mail_tags', 'show_bill', 10, 3 ); For more details please follow below links: Custom shortcode in emails Short code in ...

View answer
1 answers
0 votes
5k views
Ordering posts by custom field and grouped by month
Accepted answer
1 votes

&lt;?php $period = date("Y-m-d"); $args = array( 'post_type'=&gt;'event', 'posts_per_page'=&gt; -1, 'order'=&gt; 'DESC', 'orderby'=&gt; 'meta_value', 'meta_key'=&gt;'...

View answer
1 answers
0 votes
91 views
create importer with importer api
1 votes

I have no privileges to comment so just providing links here in answer, may this helps you: Tutorial part 1 Tutorial Part 2 Similar question: How to Create Export/Import Functionality for Plugin ...

View answer
4 answers
7 votes
8k views
Make featured image required
0 votes

f you would like to require that all posts have a featured image before they can be published add this snippet to the functions.php of your wordpress theme. When you try and publish a post without a ...

View answer
1 answers
0 votes
16 views
Change WordPress names duplicate titles (url)
0 votes

For details please see this answer : Remove Dash/Hyphen From Wordpress CustomPosttype Permalink In your functions.php : function no_dashes($title) { return str_replace('-', '', $title); } ...

View answer
1 answers
0 votes
617 views
Can i add custom code in Source in specific page, Header from function.php?
0 votes

You can add conditions in you function if you want to add icons like this method you mentioned in question. function hook_link() { global $post; if ($post-&gt;post_type == 'page' &amp;&amp; $...

View answer
1 answers
0 votes
57 views
Stop unauthorised file access
Accepted answer
0 votes

You can use this code on top of your file and apply your role condition if required : if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly For more details follow this link and other ...

View answer