Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter OffWorld

    (@offworld)

    I got it to show up on the front-end in a custom form in a custom template with:

    do_action('show_user_profile',$current_user);
    do_action('edit_user_profile',$current_user);

    Which loops in all the theme and plugin additions to the admin User Profile (but just the form elements, not any admin scripts or stylesheets that go with them). Looking at those two other threads you linked to I now see where I was probably going wrong in my form validation function.

    Ultimately for the site project in my original post I ended up using the “One User Avatar” plugin which has built-in methods for adding the form to the front-end.

    Thread Starter OffWorld

    (@offworld)

    Well that’s good to know and exactly what I need.

    Update screwed up my layout so I reverted to previous version. I just edited the version number at the top of the php file (changed it to “10.0” – though any number higher than the actual current version would work). At least now it doesn’t constantly bug me about there being an update, but it’s only a hack while I consider alternatives (or if someone just forks this plugin without the nonsense).

    Forum: Hacks
    In reply to: Show ONLY shortcode content
    Thread Starter OffWorld

    (@offworld)

    yep, the regex part is pretty much an identical case. Except the content in my shortcode doesn’t require I enqueue any scripts, so I was able to put my code right inside the loop within my single-custom.php file. Though I believe I read somewhere that WP 3.3 now allows you to enqueue scripts mid-page as well.

    I’m just glad I got it to finally work so I can move on to the next part I need to fix!

    Forum: Hacks
    In reply to: Show ONLY shortcode content
    Thread Starter OffWorld

    (@offworld)

    Ok, finally figured out something that does exactly what I want it to do. Not sure this is the “best” way, but I’ll use it since it works. Inside my loop:

    $pattern = get_shortcode_regex();
    		preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches );
    
    		if( is_array( $matches ) && array_key_exists( 2, $matches ) && in_array( 'myshortcode', $matches[2] ) )
    		{
    			foreach ($matches[0] as $value) {
    				$value = wpautop( $value, true );
    				echo do_shortcode($value);
    			}
    		} else {
    			// Do Nothing
    		}

    So I regex the post content looking for my shortcode, if it doesn’t find any instances it does nothing, if it does for each instance I grab the value of it, run it through the wpautop filter (to clean it up), then reconstruct the shortcode on the fly with do_shortcode().

    Forum: Hacks
    In reply to: Show ONLY shortcode content
    Thread Starter OffWorld

    (@offworld)

    No, it’s not a page template. It’s a single-custom.php custom post_type.

    do_shortcode() – unless I’m misunderstanding – seems to be when you want to create an instance of a shortcode somewhere it normally wouldn’t appear. But the shortcodes I’m dealing with already exist in the post and already normally appear with the unfiltered the_content().

    I’m kinda new to PHP and WP plugins so I haven’t fully wrapped my head around add_filter and apply_filters. I feel like those are probably what I want, I just don’t know how to get the output I want from them.

    Using the add_filter example on the do_shortcode codex page just spits back a number “1” and a suggestion I found somewhere online of echoing apply_filters(‘the_content’,'[myshortcode]’) gives me the shortcode wrapper HTML, but none of the $content in it, none of the $atts, and only one instance (even though the custom post has multiple instances).

    I wouldn’t think filtering the post to just display the content and atts of a shortcode would be this difficult!

    Forum: Hacks
    In reply to: Show ONLY shortcode content
    Thread Starter OffWorld

    (@offworld)

    That was the first thing I tried, figuring it’s purpose is to JUST “do the shortcode” but I’ve tried code based on the examples on that page and they just seem to filter out all the post content, including the stuff inside the shortcode.

    The only real-world examples I’ve found so far are about using shortcodes in widgets and sidebars. This is being used in a custom post_type where I have the shortcode working, I just want to get rid of anything in the_content() that isn’t the shortcode.

Viewing 7 replies - 1 through 7 (of 7 total)