how to add enfold theme shortcode to my wordpress theme - php

I'm developing a new theme for a site which is using endfold at the moment
Now, i have a problem with previous posts that have used enfold's shortcode and my theme doesn't support them how can I add enfold's shortcode to my theme

Shortcodes in Wordpress are defined likes this:
//[foobar]
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );
https://codex.wordpress.org/Shortcode_API
You have to find the defined shortcut in the endfold theme files (just grep for the shortcode alias) and reimplement this code on your theme.

Related

Overwrite $wp_customize from wordpress plugin

I am using a simple theme in WordPress, that pulls it's customizers sections from the plugin ThemeHunk Customizer.
I want to hide certain sections in the customizer section, but when using $wp_customize, it isn't working.
This is what I am trying to hide:
$wp_customize->add_section('section_home_ordering', array(
'title' => __('Section Ordering', 'featuredlite'),
'priority' => 3,
));
This is located in the /wp-content/plugins/themehunk-customizer/featuredlite/customizer/customizer.php file.
I have added this to my functions.php file in my child theme directory:
function customize_register_init( $wp_customize ){
$wp_customize->remove_section('section_default_home');
$wp_customize->remove_section('pro_button');
$wp_customize->remove_section('Docs_button');
$wp_customize->remove_section('section_home_ordering'); - THIS IS THE SECTION I would like removed from the /plugin/ file
}
add_action( 'customize_register', 'customize_register_init', 99 );
It doesn't seem to remove though, like it would if you were removing a section from a parent theme.
Is there another method to do this, or is this not possible to remove from a plugin rather than a parent theme?
Thank you in advance.
SOLVED I use the customize_controls_enqueue_scripts hook to input custom CSS within the wordpress customizer, so I can display certain elements as hidden!
In theme your code works fine. Maybe it depends on action hooks order.
Have you tried?
add_action( 'plugins_loaded', 'customize_register_init', 99 );
You can simply go with these documentation as it shows you can disable particular section of Home Page (FrontPage). You can change order of appearance also from the Appearance > Frontpage Section > Section Ordering.
Reference Link: https://themehunk.com/docs/shopline-theme/#frontpage-section
https://themehunk.com/product/shopline-free-shopping-theme/

Replacing Woocommerce Storefront header with a shortcode

I am using Woocommerce Storefront theme and I want to replace the original header with a custom header that I created in elementor. I have a shortcode for the new header but I don't know how to insert it into the code. I am using a blank storefront child theme and there is a function.php file and style.css file.
Thanks for the help.
Just copy the header.php from the parent theme and paste it inside the child theme. Then you can already put your custom code in it.
Reference: codex.wordpress.org/Child_Themes
You can do this in your child theme by using a hook on init
Something like this:
add_action('init', 'replace_header' );
function replace_header(){
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
add_action('storefront_header', 'my_custom_header', 50);
}
function my_custom_header(){
do_shortecode('[your_elementor_header_shortcode attr1="value1"]')
}

Add short product description to Widget products in WooCommerce

it is possible to add short description to the products list in the woocommerce products wordpress widget?
How I do it?
I'm not a pro, be easy in your answers, please!
Thanks
You should need to override WooCommerce content-widget-product.php template via your active theme. Here is a documentation related: Template structure & Overriding templates via a theme
So you will need to create a folder named woocommerce in your active child theme (or active theme), if not done yet, in which you will copy the file located in:
wp-content/plugins/woocommerce/templates/content-widget-product.php
to:
wp-content/themes/your-child-theme/woocommerce/content-widget-product.php
Once done you will add after the line 34 the following:
<div class="produc-excerpt"><?php echo $product->get_short_description(); ?></div>
This will add the product short description for each product in the Widget Products output list.
In upcoming WooCommerce version 3.3, you will be able to replace that using a custom function hooked in dedicated woocommerce_widget_product_item_end action hook:
add_action( 'woocommerce_widget_product_item_end', 'add_excerpt_to_widget_products', 10, 1 );
function add_excerpt_to_widget_products( $args ) {
global $product;
echo '<div class="produc-excerpt">Bla: '. $product->get_short_description(). '</div>';
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works only in WooCommerce version 3.3+.

Custom excerpt for child template on Wordpress

I've been creating a child Wordrpess theme. The parent theme is TwentyTwelve theme.
I override styles.css file and it works perfectly. But I can't replace the_excerpt function on my functions.php
I've been searching but I can't find the solution.
functions.php
<?php
function custom_excerpt($text) {
return "Test";
}
function my_child_theme_setup() {
add_filter('the_excerpt', 'custom_excerpt');
add_filter('get_the_excerpt', 'custom_excerpt');
add_filter('default_excerpt', 'custom_excerpt');
}
add_action( 'after_setup_theme', 'my_child_theme_setup' );
?>
I just wan't to show the featured image on the excerpt linking the original post.
Thanks!

How to make Wordpress Short-code for recent posts

I want to create a simple Wordpress shortcode for recent posts to use it inside a post.
I know the basic steps of creating a shortcode:
1- I open the WP theme "functions.php" file and include a new custom file created in same directory i name it "custom-shortcode.php"
2- Inside the "custom-shortcode.php" i write the actual code:
<?php
// Shortcode function
function custom_shortcode() {
// Use WP recent posts function with default values return
return php wp_get_recent_posts( $args, $output );
}
// Add shortcode (WP function)
add_shortcode( 'recent-post', 'custom_shortcode' );
?>
I want to use the wp default function for getting recent posts, is my code will work?
I want to get shortcode with minimal code and with default values return so i can focus on learning how can i make my own shortcode.
Use
shortcode_atts(array( for make your custom style..
You can follow , http://codex.wordpress.org/Shortcode_API

Categories