Shortcodes on my website stops working after theme update [closed]

most likely your [download_ebook_lead_form ret_url=””] shortcode was defined in functions.php in your theme parent folder, and during update the file was somehow replaced with new one. If you have backup of previous version of your theme check its functions.php and look for add_shortcode( ‘download_ebook_lead_form’…). If you find it there just copy entire function to functions.php … Read more

Optimizing a WordPress site

Functions and shortcodes that are never used, eat some processor time at launch, as WP is registering their existence. Deregistering them would take up some additional (and minimal) processor time. Because they are loaded with functions.php they will reside in memory, either registered or deregistered. Which amounts to the same, as the code is never … Read more

Excecuting php function in shortcode

This will probably not work, or work in unexpected way. Shortcodes should probably be displayed only on a “post” single page. Using a shortcode in the way you want will either make the breadcrumbs not to be displayed on archive pages or have them displayed there multiple times or wrong places. What you should do … Read more

Page code showing in WP Dashboard

Shortcodes should not echo any output. They should always return the text that is to be used to replace the shortcode. You either write the html code on a variable: function my_shortcode() { $output=”<div>something</div>”; return $output; } Or you can use php output buffering: function my_shortcode() { ob_start(); ?> <div>something</div> <?php return ob_get_clean(); } In … Read more

Namespaced shortcode?

Unfortunately, this is not how shortcodes work. Your solution will not reduce performance problems. At initialization the only thing WordPress does is make a list of all shortcodes that are being registered. If you look at the order in which WordPress is loading stuff you will see that plugins are loaded before the theme and … Read more

Code is providing a row of data but not formatting it as table

It’s not displayed as table, because you don’t return correct HTML code. Let’s take a look at your code (I’ve put comments at end of incorrect lines): $content=”<table>”; $content .= ‘</tr><th>Week Beginning</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th><th>Weekly Total</th><th>Previous Week Totals</th></tr>’; // <- here you open TR with </tr>, so it’s already incorrect $results = $seconddb->get_results( ‘ SELECT * FROM seconddb_PontoonBoats_LineOne_2Log’ … Read more

Just display content between shortcode brackets

I have good news: the answer is simple. The WordPress Codex concerning Enclosing Shortcodes (like the one you posted here) shows that the shortcode callback has 2 arguments, $atts and $content. You want to work with $content: function wporg_shortcode($atts = [], $content = null) { // do something to $content // always return return $content; … Read more

How to retrieve category of a post in have_post loop?

wp_get_post_categories() and get_category() are specifically for the category taxonomy. You’re using a custom taxonomy, portfolio_cat, so you need to use get_the_terms() to get categories. $categories = get_the_terms( $post_id, ‘portfolio_cat’ ); $cat_str=””; foreach ( $post_categories as $category ) { $cat_str .= $category->name; } If you just want a comma separated list of category links, you can … Read more