andrewbecks
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Conditional template based on shortcodeAs is pretty much always how it goes, I figure it out moments after I ask for help. Anyway, in case anyone is interested, here’s my solution:
Start with an additional function inside function.php
function has_custom_shortcode($shortcode = '') { $post_to_check = get_post(get_the_ID()); $found = false; if (!$shortcode) { return $found; } if ( stripos($post_to_check->post_content, '[' . $shortcode) !== false ) { $found = true; } return $found; }
(Adapted from something I saw here.)
Then, I was able to simply leverage the function in my OR condition:
if (has_custom_shortcode('test') === true)
That’s all it takes.
Forum: Plugins
In reply to: [Main Category As Subdomain] Preserving query string parameters on redirectExcellent. Thanks for your help.
I needed it to be a little more dynamic, to capture the various Google Analytics tracking params, but what you provided was perfect.
I’m pasting my completed code here, in case it can help anyone else out.
Thanks again!
// Preserve query string params in redirect (for use with subdomains plugin) add_filter( 'post_link', 'to_post_link' , 10, 2 ); function to_post_link( $post_link , $post ) { $qsSeperator = '?'; $qsAppend = ''; // Preserve utm_source variable in querystring on redirect if ($_GET['utm_source'] <> '') { $qsAppend .= $qsSeperator.'utm_source='.$_GET['utm_source']; $qsSeperator = '&'; } // Preserve utm_medium variable in querystring on redirect if ($_GET['utm_medium'] <> '') { $qsAppend .= $qsSeperator.'utm_medium='.$_GET['utm_medium']; $qsSeperator = '&'; } // Preserve utm_campaign variable in querystring on redirect if ($_GET['utm_campaign'] <> '') { $qsAppend .= $qsSeperator.'utm_campaign='.$_GET['utm_campaign']; $qsSeperator = '&'; } // Preserve utm_term variable in querystring on redirect if ($_GET['utm_term'] <> '') { $qsAppend .= $qsSeperator.'utm_term='.$_GET['utm_term']; $qsSeperator = '&'; } // Preserve utm_content variable in querystring on redirect if ($_GET['utm_content'] <> '') { $qsAppend .= $qsSeperator.'utm_content='.$_GET['utm_content']; $qsSeperator = '&'; } // Return URL with complete query string return $post_link . $qsAppend; }
Forum: Hacks
In reply to: Adding an additional paginated page to the_contentThat seems to work perfectly, Gagan Deep Singh. I wasn’t familiar with the post_results filter, so I really appreciate the assistance.
Forum: Fixing WordPress
In reply to: Custom rewrite rule now working with custom_rewrite_basicYou are a genius! Thanks, Dipak. I was missing the step where you save the Permalinks to regenerate and flush the rewrite rules from the database.
Thanks again!
Forum: Fixing WordPress
In reply to: Custom rewrite rule now working with custom_rewrite_basicIf I navigate directly to index.php/?cat=9&video=517339714, I’m successfully redirected to
article/category/videos/?video=517339714, so I know that the category ID is correct.Forum: Fixing WordPress
In reply to: Custom rewrite rule now working with custom_rewrite_basicThanks, Dipak. That didn’t seem to work, either. (Still returns a 404 error.) I’m putting this in my functions/user/functions.php file (within the theme directory).
The XXXX ID will only be numbers.
Forum: Fixing WordPress
In reply to: Custom rewrite rule now working with custom_rewrite_basicThanks for the suggestion, satishpandit. I’m currently using permalinks for posts, but what I’m trying to do applies to the category page, so I’m afraid that the link you provided didn’t give me quite what I needed.
Forum: Fixing WordPress
In reply to: New Permissions Errors When Accessing WP AdminTara – That worked. You are a lifesaver! I literally cannot thank you enough. I have previously tried re-uploading the wp-admin directory from scratch, but no luck. Reuploading wp-includes totally fixed the issue. Thank you again! (If you’re in the US, have a Happy Thanksgiving.)
Forum: Fixing WordPress
In reply to: New Permissions Errors When Accessing WP AdminIn /wp-admin/includes/menu.php, I swapped the following code:
if ( !user_can_access_admin_page() ) { /** * Fires when access to an admin page is denied. * * @since 2.5.0 */ do_action( 'admin_page_access_denied' ); wp_die( __('You do not have sufficient permissions to access this page.') ); } $menu = add_menu_classes($menu);
With
if ( !user_can_access_admin_page() ) { $a = array( 'Pages No Access' => $_wp_menu_nopriv, 'User Info' => $current_user, 'Roles' => $wp_roles->get_names(), ); $s = sprintf("\n<br /><pre>%s</pre>", print_r($a, true)); do_action('admin_page_access_denied'); wp_die( __('You do not have sufficient permissions to access this page.'.$s) ); } $menu = add_menu_classes($menu);
Forum: Fixing WordPress
In reply to: New Permissions Errors When Accessing WP AdminHi Tara – No luck on that. Reverting to the default TwentyFourteen theme showed the site, but I still get the same error when logging in to WP admin. I should mention that there is another admin user getting the exact same results on login (same error).