Tag Info

New answers tagged

1

Before starting answer I have to say that regarding this topic css and js are not the same. Reason is simple: while adding js to the body of the page (in footer) is a common and valid way to act, css need to be in the <head> section of the page: even if majority of browsers can proper render css in page boy, it is not valid HTML code. When a ...


0

It's easier to remove specific shortcodes than it is to remove_all_shortcodes() and enable specific shortcodes. To disable specific shortcodes from display everywhere, you would use the following: <?php add_filter( 'the_content', 'oxo_remove_shortcodes', 0 ); function oxo_remove_shortcodes( $content ) { /* Add the shortcodes that you would like ...


0

According to Codex: This will create [foobar] shortcode that returns as: foo and bar With attributes: // [bartag foo="foo-value"] function bartag_func( $atts ) { $a = shortcode_atts( array( 'foo' => 'something', 'bar' => 'something else', ), $atts ); return "foo = {$a['foo']}"; } add_shortcode( 'bartag', ...


1

I'd try to use author IDs rather than the username: if ( get_current_user_id() == get_the_author_meta( 'ID' ) ) { echo "It is my site."; else { echo "It's not my site"; }; References get_current_user_id get_the_author_meta


2

Per the Codex, is_author() checks to see if you're on an Author Archive page (ie, a page listing all the posts/pages/etc that a given user has authored). If you're on any other type of page, is_author() will return false. What you're looking for sounds more along these lines: if ( in_the_loop() ) { get_currentuserinfo(); print ( get_the_author() ...


0

I would use the filter wp_audio_shortcode: /** * Filter the audio shortcode output. * * @since 3.6.0 * * @param string $html Audio shortcode HTML output. * @param array $atts Array of audio shortcode attributes. * @param string $audio Audio file. * @param int $post_id Post ID. * @param string $library Media library used for the audio ...


1

You could try running the content of the custom field through the do_shortcode() function when you output. e.g. given a custom field name of 'custom field' echo do_shortcode( get_post_meta($post->ID, 'custom-field', true) );


1

<?php function url_fetcher(){ $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ...


0

I don't think you can do this by using shortcodes, but of course you can create your own shortcode and put in your own custom PHP. There are three things you want to do: Grab the URL and split it up into an array Grab the part of the URL you want from the resulting array Explode the variable on the - and output it in a or multiple variables, which can ...


1

Rather than add a rule to .htaccess, you can use a WordPress rewrite to do this: function cdl_rewrite_rule(){ add_rewrite_rule( 'cdl-manual/([-a-z]+)/?$', 'index.php?pagename=cdl-manual&jp_stn=$matches[1]', 'top' ); } add_action( 'init', 'cdl_rewrite_rule' ); This is assuming you've already added jp_stn to the list of ...


0

The reason you are getting a 404 is that the rewrite rule do not change the request URL as reported sin $_SERVER[REQUEST_URI] variable of PHP, and wordpress parses that variable when deciding what content is request and since there is no such page /cdl-manual/arizona/ it displays a 404. What you need is a wordpress rewrite rule to parse the url the way you ...


1

As you mentioned in the comment, inside-context paragraphs will be just next to clicked anchor's parent, this code will work: $(".btn-context").on('click', function (event) { event.preventDefault(); $('.inside-context').removeClass('open'); $(this).parent().next('p.inside-context').addClass('open'); });


1

There are several minor problems with your code: Firstly, you are using shorthand PHP tags, like <?= /*some stuff*/ ?> they won't work - see WordPress Coding Standards - No Shorthand PHP Tags. Secondly, you are not echo'ing the variable $client_name. Last but not least, you are saving your post meta with the name _client_name, with an additional ...


1

Okay, you need this: <?php echo do_shortcode('[your-first-shortcode]'.'[your-second-shortcode]'); ?> Just write a dot between your shortcodes... Try: <?php echo do_shortcode( '[vc_row][vc_column width="1/1"][vc_accordion][vc_accordion_tab title="Section ...


2

You just forgot to return the excerpt for the other post types. Try for example: function do_my_shortcode_in_excerpt( $excerpt ) { if ( 'services' == get_post_type() ) $excerpt = do_shortcode( wp_trim_words( get_the_content(), 55 ) ); return $excerpt; } add_filter( 'get_the_excerpt', 'do_my_shortcode_in_excerpt' );


0

A simple way, use $tag variable within your shortcode function. Get this idea from here add_shortcode("your_shortcode_tag", "shortcode_function"); function shortcode_function($atts, $content = null, $tag){ // $tag variable is here // check if your shortcode is called if($tag == "your_shortcode_tag"){ // do your stuff } }


0

You are not using proper syntax, so you are likely getting a syntax error. You are using some strange sign in your code where you should be using a single quote ('). Also, use curly brackets to enclose a condition. It is easier to debug <?php if(function_exists('wooslider')){ echo do_shortcode('[wooslider slider_type="posts" limit="3" ...


0

there isn't an "space" in the Shortcode-Name. What you have, is an shortcode called "customcont", that is providing an Parameter called "form". So this is, how it should work: function example_shortcode( $atts = array(), $content = '' ) { extract( shortcode_atts( array ( 'form' => 0, ), ...


0

What I found to work for me was to remove the action within the foreach ending with the following code function pmc_gallery_menu_order_fix($id) { $regex_pattern = get_shortcode_regex(); preg_match ('/'.$regex_pattern.'/s', stripslashes($_POST['content']), $regex_matches); if ($regex_matches[2] == 'gallery') : $attribureStr = str_replace ...


0

TinyMCE is programmed to make editing easy (which for us HTML savvy is often not the case). By default is should not accept <p> tagging around [BLOCKS]. That is because "[]" are used for shortcode not only in WP but a ton of PHP based CMSs. The shortcodes should have the appropriate content wrapper. Meaning the solution is to add the <p> ...



Top 50 recent answers are included