Support ForumChanging Shortcode File in Child Theme – Support Forum https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/feed/ Sun, 28 Apr 2024 13:41:32 +0200 http://bbpress.org/?v=2.5.12-6148 en-US https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-840 <![CDATA[Changing Shortcode File in Child Theme]]> https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-840 Fri, 04 Oct 2013 16:49:53 +0000 johnnyspade There’s a few formatting changes I would like to make to the Recent Posts shortcode. I know that this is rendered here:

minicorp/assets/framework/wp/shortcodes/shortcodes.php

I don’t want to change that file in the main theme directory to preserve upgradeability, but can I copy this directory structure into the child theme, and change the shortcodes.php file there?

minicorp-child/assets/framework/wp/shortcodes/shortcodes.php

Any advice appreciated.

]]>
https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-843 <![CDATA[Reply To: Changing Shortcode File in Child Theme]]> https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-843 Sat, 05 Oct 2013 13:13:11 +0000 IshYoBoy Hi Brandon,

This is a great question! If you would like to copy the whole file and load it from the child theme you’ll have to make a few changes in the parent theme. These changes will be part of the next theme version so they are update safe.

Please open the file:
“wp-content\themes\minicorp\assets\framework\wp\options\init.php”

and completely change its content to contain only the following lines:

Once done you will be able to override the whole “shortcodes.php” file in your child theme by simply putting in the exact same folder structure as it is in the parent theme.

Although this would solve your problem we do not recommend overriding the whole file as it would mean that none of the changes we make to it in future updates will be reflected as they will not be loaded. This file contains all shortcodes which are very crucial to the theme as almos all the content is created using shortcodes. If you would like to edit only the recent_posts shortcode which is just 1/50th of all content, then please better do it using the following method.

1. Open the parent theme “shortcodes.php” file and find the [recent_posts] function (line 2147) and surround it using the following code:

so on line 2147 add:

if ( !function_exists('ishyoboy_shortcode_recent_posts') ) {

and on line 2718 add:

}

2. Now copy the whole “ishyoboy_shortcode_recent_posts” fuction and add it to your child theme’s “functions.php” file and make the changes there.

This way you will only override the [recent_posts] shortcode and all remaining shortcodes will remain update-able as they will still be loaded from the parent theme. The first step will also be a part of the future update to make it easier for you guys to override shortcodes in child-themes.

Hope this helps. Please let us know if it worked and please tell us you have chosen the second method :)

Have a nice weekend,
Cheers!

A 5 star rating is always a great motivation for us if you are happy with our theme or support!
Themeforest | MojoMarketplace | Creative Market

]]>
https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-864 <![CDATA[Reply To: Changing Shortcode File in Child Theme]]> https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-864 Mon, 07 Oct 2013 13:16:14 +0000 johnnyspade Perfect. Thanks for all your help.

The change I’ve made here, which may be something you want to consider for the shortcode in general, is to give the user the option of using the content of WordPress’ “Excerpt” field as the content displayed underneath the Recent Posts title, rather than using the content from the WYSIWYG and truncating it at 30 characters. So, if the “Excerpt” field is populated, use that text instead of what’s in the WYSIWYG.

I’ve also moved the post thumbnail above the post title, instead of below. It displays a little nicer when there’s long titles that need to wrap over more than one line.

]]>
https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-874 <![CDATA[Reply To: Changing Shortcode File in Child Theme]]> https://support.ishyoboy.com/forums/topic/changing-shortcode-file-in-child-theme/#post-874 Mon, 07 Oct 2013 15:07:02 +0000 IshYoBoy Hi,

these are small tweaks that users can do themselves based on their page’s needs. But we will consider adding it.

Glad you manged to make the changes you needed,
Cheers

A 5 star rating is always a great motivation for us if you are happy with our theme or support!
Themeforest | MojoMarketplace | Creative Market

]]>