Tag Info

New answers tagged

1

It's doable with a user agent string "sniffer". Take a look at this project: http://mobiledetect.net Mind you, this approach can be troublesome as most modern browsers can 'fake' their user agent strings. Also, this approach doesn't work to well with caching systems. I've implemented it successfully on a project I worked on, and I know it's possible but ...


0

You can add the following code to your function.php, I Never test this but I believe it should solve the problem for you. One thing you needed to do while making use of the code is to change the custom-post-type1... to the name of your own CPT. function add_my_CPT( $query ) { if( is_category() || is_tag() && empty( ...


1

My solution to this problem when extending the Walker_Nav_Menu was to skip check if current_page_parent when C.P.T. I identified C.P.Ts following this stackexchange post. This does not entirely solve the problem as I am using current_page_item for C.P.T parent menu items, but it does achieve the desired outcome. Here is my class. class My_Menu extends ...


1

Remove query_posts and add a pre_get_posts action to your functions.php file to modify sort order: function wpd_category_sort_order( $query ) { if ( !is_admin() && $query->is_category() && $query->is_main_query() ) { $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'wpd_category_sort_order' );


0

This approach is not advisable as http://example.com/page/whatever-information/ is how Wordpress deals with child pages and .htaccess Rewrites is part of how Wordpress identifies what page is being requested and what queries to run. You should probably pass the whatever-information as something called a POST variable, then have code that runs on page and ...


2

I would recommend using the category_template filter - just check if the current category is an ancestor of 67: function wpse_179617_category_template( $template ) { if ( cat_is_ancestor_of( 67, get_queried_object_id() /* The current category ID */ ) ) $template = locate_template( 'category-slider.php' ); return $template; } add_filter( ...


1

Yes. you can do that. function my_custom_footer() { ?> <div class="site-footer-logo"> <img src="<?=get_stylesheet_directory_uri();?>/images/my-logo-small.png" alt="My Logo Small" /> </div> <?php do_action('my_own_hook'); ?> <p>Copyright &copy; <?=date('Y');?>, my-url.com.</p> ...


0

Whether a form will display in a particular email clients (ie, Mail for iPhone or Gmail on your desktop) is up to that email client. The way a lot of companies will handle this is to have three choices, say, in the email, each would be a link: Are you a good person? A. Yes B. No C. It's all opinion The links would have parameters like: A. Yes // ...


1

When working with shortcode you must return a value rather than output directly. The below amendmetn should fix your positioning issue. For more informaiont, see the Shortcode API Codex, speciffically the Output section. function multipage_form() { global $wpdb; $this_page = $_SERVER['REQUEST_URI']; $page = $_POST['page']; ...


0

You can hook the content of any post and request data you want through WordPress HTTP API. Like this: add_filter('the_content', 'my_content_178750', 1, 99); function my_content_178750($content) { return wp_remote_retrieve_body(wp_remote_get('http://example.com')); } Also there is possibility to check path you're on and decide what you want to get ...


0

echo esc_url( home_url( '/' ) ); this best practice. get_bloginfo( $show, $filter ); It has lots of Parameters to get info so let see the ##SHOW(Parameters): ...


0

As per Skribe wrote before... I will just try to give more details on what he meant if you are not already used to what are shortcodes... Shortcodes have been created to display different content in different manners, when they are incorporated in posts or pages. You can see here a current list of existing shortcodes included inside WordPress (as per ...


0

Yes there is a simple way to make it work with most any template. This is the exact reason so many plugins use shortcodes to inject data or other wise add whatever feature the plugin is designed for. Template structure is far too unpredictable, to do it the way you are currently pursuing. So right from the API it is simple as naming your shortcode and ...


0

Can you not just create a Page Template which duplicates the home.php functionality and then remove whatever you need to from that? http://codex.wordpress.org/Page_Templates


0

You could filter home_template, check for the presence whatever $_GET var is reliably set for each of those requests, and load a different template for those cases. function wpd_home_template( $home_template = '' ){ if( isset( $_GET['search_type'] ) ){ $home_template = locate_template( 'homesearch.php', false ); } return $home_template; ...


3

From the Codex If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage: add_filter( 'wp_title', 'baw_hack_wp_title_for_home' ); function baw_hack_wp_title_for_home( $title ) { if( empty( $title ) ...


6

It looks like your site's title is empty. Fill it out or try for example: add_filter( 'wp_title', function( $title ) { return trim( $title ); } ); to remove the blank space in front. For your setup, the following part of wp_title() is responsible for the blank space: $title = $prefix . implode( " $sep ", $title_array ); So when you're on a single ...


2

This is the code I'm using, it's a custom nav walker for BootStrap but you could easily adapt it to your own. By the way, you could copy & paste my nav walker and be sure to change this line: $class_names .= ' dropdown'; to $class_names .= ' sub-menu'; Hope this helps. /** * Custom Bootstrap Nav Walker */ class macho_bootstrap_walker extends ...


0

As you have now stated that both Theme A and Theme B are already Child Themes, perhaps you could try adding this to your funcions.php file in Theme B - add_action('wp_enqueue_scripts', 'enqueue_front_scripts'); function enqueue_front_scripts(){ /** Switch to the parent blog */ switch_to_blog(1); // You may need to change the ID, I don't know what ...


0

You could make Theme B a Child Theme of Theme A, and then create header-b.php in Theme B (as opposed to header.php), then just include that after your call to get_header(); require_once("header-b.php") To ensure that all of your styling is carried over from the parent, include this in your functions.php file of Theme B - add_action('wp_enqueue_scripts', ...


0

For custom page templates, I would use page_about.php or page_services.php. Make sure you add the following after the opening PHP tag: /* Template Name: About Page */ Custom page templates can be uploaded to your themes root directory or a sub folder named page-templates. If creating a page template for a specific page, use the following: ...


0

Just figured out the answer. It needs to be echo'd, so echo site_url works. Or to use in a template <?= site_url(); ?>


1

If you wrote in a conditional on the home.php or index.php couldn't you loop through with get_template_part(); ?


0

The new user notification email is created and sent by the function wp_new_user_notification(), found in wp-includes/plugable.php There is no filter hook within this funciton that will allow you to manipulate the output of the email, however you can of course overwrite any pluggable function via a plugin. Note - You can only overwrite pluggable functions ...


0

I found this function which gets rid of the 32px 'bump' left over after using "show_admin_bar(false)" remove_action('wp_head', '_admin_bar_bump_cb'); That seems to do the job!


0

Here is a basic idea: Any page where the page parent ($post->post_parent) is 0, it means the page is a top level page. If any other value exists, the page is a child of another page. This value is the ID of the page that the specific page is a child to. With the above information, we can calculate if the page is a child or a granchild using get_post and ...



Top 50 recent answers are included