Is there a way to make a conditional tag that tests if it is search-no-results page? I know that there is a function to check if is_search() page: if(is_search()){ echo "search page"; } But I didn't found a way to check for search-no-results, and I noticed that WordPress gives body class with search-no-results to this page.
I have a plugin that requires scripts to load for an admin panel in the page-attributes template drop-down on page post type. However this script causes a Uncaught TypeError: on post post types which is a correct response and I understand that is not where my focus should turn. Since this script is only necessary for the page post type, I believe the best solution is to conditionally format my script so it works as such. Due diligence was taken …
I have those 2 pages that are created from a plugin (see the plugin https://zombify.px-lab.com/frontend-page/, just login and choose a post type, check the url): https://www.domain.com/post-create-page/?type=story https://www.domain.com/post-create-page/?type=trivia The plugin is making use of custom post type. I have been trying to target them if (is_page ('post-create-page') && ... ) with get_query_var by trying to pass the $qvars to add_filter( 'query_vars' but I am not sure how to do that. Could some one help me how i could target those 2 …
I came across the need to have a site Editor to edit menus. I found some answers that suggest the add_cap() approach, to add the edit_theme_options capability to Editor role. This should be done once and then removed from functions.php: // Do this only once. Can go anywhere inside your functions.php file $role_object = get_role( 'editor' ); $role_object->add_cap( 'edit_theme_options' ); The same answer shows a way to hide unwanted Appearance sub-menus. But it also hides those sub-menus to Administrator role. …
I'm trying to display a custom widget in the sidebar of my homepage (which is a static front page defined in Settings > Reading). Here is the relevant part of my sidebar.php: if ( is_front_page() || is_home() ) { if ( is_active_sidebar( 'sidebar_lecture' ) ) : ?> <div id="secondary" class="widget-area" role="complementary"> <?php dynamic_sidebar( 'sidebar_lecture' ); ?> </div> <?php endif; The sidebar does not display because the conditional tag does not recognize my homepage as being a homepage. When I print_r($wp_query) …
Having an issue where I have a client who wants his Google Analytics code on just one page. I'm using the following is_page code but in the footer.php of my child theme, but it's not appearing on the page. Is this code correct? <?php if ( is_page( 'contact' )) { echo '<script type="text/javascript">/* <![CDATA[ */ var google_conversion_id = 000000000; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "000000000"; var google_remarketing_only = false; /* …
I'm trying to hide the word "Category:" from the metadata on the Twenty-Eleven theme's footer, when I don't have one set for a given post (sometimes I will manually remove the "Uncategorized" category, and sometimes I will be using Custom Post Types with Categories I have yet to create). I know how I can do it with my custom post types' versions of "categories" and "tags:" <?php if (get_the_term_list( $post->ID, 'length' ) != null ) { ?> <div>Length: <?php echo …
I am looking for a way to test if a post is a custom post type. For example, in, say, the sidebar I can put in code like this: if ( is_single() ) { // Code here } I want code testing for only a custom post type.
I can see that the 2 functions are almost identical. Only difference is in one line: @is_admin() return $GLOBALS['current_screen']->in_admin(); @is_blog_admin() return $GLOBALS['current_screen']->in_admin( 'site' ); What is the practical purpose / reason behind this? Or where can i read more about it? I can see that is_blog_admin() 'born' much later, and since it's giving the 'site' parameter to the in_admin() function that it calls internally, it works as a stricter condition, thus being more specific and probably not good idea to …
I'm creating some dynamic content but I need to run a conditional is_single() check inside the php function add_action( 'wp_ajax_rando_func', 'rando_func' ); add_action( 'wp_ajax_nopriv_rando_func', 'rando_func' ); function rando_func() { if (is_single()) { //do stuff } } This doesn't work so I tried adding the ID function rando_func() { $page_id = $_POST["page_id"]; if (is_single($page_id)) { //do stuff } } No luck with that either. How do I accomplish this?
I am using this to load css styles in the admin area (for any user who is not an administrator): function wpse_admin_styles() { if ( !current_user_can( 'manage_options' ) ) { echo '<style> .fun-stuff-here {color:aqua;} </style> '; } } add_action('admin_head', 'wpse_admin_styles'); But I need to have some styles only load if the admin page being viewed is a page (not a post or custom post type post) Is this possible? I think the answer selected in this WPSE question has some …
Is this even the correct way of including scripts on a specific page? function insert_mapsvg_scripts() { wp_enqueue_style( 'mapsvg_css', site_url('/mapsvg/css/mapsvg.css') ); wp_enqueue_style( 'nanoscroller_css', site_url('/mapsvg/css/nanoscroller.css') ); wp_enqueue_script( 'mousewheel_js', site_url('/mapsvg/js/jquery.mousewheel.min.js'), array('jquery'), '', true ); wp_enqueue_script( 'nanoscroller_js', site_url('/mapsvg/js/jquery.nanoscroller.min.js'), array('jquery'), '', true ); wp_enqueue_script( 'mapsvg_js', site_url('/mapsvg/js/mapsvg.min.js'), array('jquery'), '', true ); } if( is_page( 37629 ) ) { add_action('wp_enqueue_scripts', 'insert_mapsvg_scripts'); }
I have just migrated my websites from HTML to WordPress version. I have saved all my Posts on a txt file. Now after I imported to WordPress all the HTML (h2 and h3 ) tags inside the contents of the post are missing Are there any WordPress plugins or any codes, that can automatically add h2 or h3 tags to my post paragraphs based on word counts, single sentences, or Question Mark? Example of my posts: Lorem Ipsum is simply …
How can I check if the current shortcode is being used in a widget? I need to disable some shortcode options that are not allowed in a widget. Someone know how?
Is there a way to avoid displaying tags which have less than X Posts? the answer here is close Remove from Google Tags with less than 2 posts however it suggests to send a respose header to google. I would ideally like to NOT have these tags in my sitemap so that google does not index these pages which are basically duplicates of the original post with a different tag, not a good thing for SEO!
I want to add some gravity forms filters in my functions.php. I have the code up and running, but I would like to improve this snippet with a condition. As I only need these filters on 1 page of my website, it doesn't make sense for it to run site-wide. I'm not a programmer. I tried a couple of ways to put this code snippet under the condition: "if (is_page( array( 'post-form' ) ) ) {" but without success. I …
I'm using this technique: https://stackoverflow.com/questions/27323460/how-to-label-payments-in-gravity-forms-paypal-pro To add comments to the paypal comments field from a gravity form. However, it's a multisite configuration. I'd like to modify it so the filter only triggers on blog_id 2 What's the proper method to make this conditional? Much thanks.