Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:03:47+00:00 2026-06-15T14:03:47+00:00

I want to create a shortcode to style existing content on a page. function

  • 0

I want to create a shortcode to style existing content on a page.

function myShortcode(){    
    $mycontent = '<div class = "columnstyle">'; 
    $mycontent .= ...existing content wrapped in a <p> tag... 
    $mycontent .= '</div>';
    return $mycontent;
}
add_shortcode('columnstyle', 'myShortcode');

The existing ‘p’ tag:

<p class='first'>blah blah blah</p>

How do I assign $(‘.first’) to $mycontent? I don’t think this is working…

$mycontent .= $('.first');

Update:

I knew $(‘.first’) is a javascript variable as I didn’t know how to reference it in PHP. The next function I am going to carry out is:

function myShortcode_call(){    
    ?>        
        <script type="text/javascript">                
            jQuery(document).ready(function($){                     
                $('.first').before("<?php echo do_shortcode('[columnstyle]'.myShortcode().'[/columnstyle]');?>");

            });
        </script>
    <?php
}
add_action('thesis_hook_after_html','myShortcode_call');

The result is to style the content “blah blah blah” on the page with the short code [columnstyle].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:03:48+00:00Added an answer on June 15, 2026 at 2:03 pm

    I think this is what you want. Are you working with wordpress?

    http://codex.wordpress.org/Function_Reference/do_shortcode

    function myShortcode($shortcode){    
        $mycontent = '<div class = "columnstyle">'; 
        $mycontent .= $shortcode;
        $mycontent .= '</div>';
        return $mycontent;
    }
    add_shortcode('columnstyle', 'myShortcode');
    
    function myShortcode_call(){    
        ?>        
            <script type="text/javascript">                
                jQuery(document).ready(function($){                     
                    $('.first').before("<?php echo do_shortcode('[columnstyle]'.myShortcode().'[/columnstyle]');?>");
    
                });
            </script>
        <?php
    }
    add_action('thesis_hook_after_html','myShortcode_call');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create a ModelForm class where model is a parameter passed from the
I want create a new JavaScript object based on an existing JavaScript object. Till
I want create a DataSet class which is basically a list of samples. But
I am trying to create a Wordpress shortcode-style feature in PHP to replace shortcodes
I want create a new <li> component, then add href, class, etc.. and finally
I want create a div container with a message for first time visitors to
I want create new table out of magento, in interface, without inheriting setup class.
Hi I want create an effect like below: http://img27.imageshack.us/i/19466828.png/ There is a class in
I want create my own shortcode In the text i can put the shortcode
I want create a plugin in jquery. this is my html code : <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.