Tag Info

New answers tagged

1

First of all, I'd strongly recommend against storing translations for a plug-in in your theme. It has no reason to be there, and you'll loose the translations when you change/update the theme. The correct place to store translations is wp-content/languages/plugins/. This code does that, and targets the domain 'other_plugin': function ...


0

While Ray's answer is perfectly correct you might want to use some geeky stuffs such as Vagrant which allows you to do quite the same as WAMP , XAMP, MAMP but in a more flexible way. The idea is to exactly match the production server. May I suggest you to use child themes also. It's the best way to edit/modify a theme.


0

There are several plugins that will allow you to clone the database only, as well as the WordPress installation and media files. You will need to install a WAMP, LAMP or MAMP stack or XAMPP. Upon completion of your updates, you can migrate the site back to the host server.


1

Go into your themes single.php file and put this code in a proper place under the the_title(); This Post was written by <?php the_author(); ?>


0

If you post your header.php code then I could help you better. But I cannot comment as I do not have 50 rep. But referring to your website I checked the code and there is this tag from where this is coming from. If you modify your h1 tag and add your logo in it the logo should appear. <h1 class="site-title"><a href="<?php echo esc_url( home_url( ...


0

You can go to the theme editor, open the header.php model and replace the content <div id="header-text"> <h1 id="site-title"> <a href="http://www.physics4all.com/" title="Physics for All" rel="home">Physics for All</a> </h1> <h2 id="site-description"></h2><!-- ...


4

You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce. <?php if ( class_exists( 'WooCommerce' ) ) { // code that requires WooCommerce } else { // you don't appear to have WooCommerce activated } ?>


0

You have it right @Hassan Alvi, you should use get_template_part() for each stage of your one pager. Dont use id use specific class instead, it's more object oriented. It will make you code a lot more readable and more easy to maintain!


0

Extending Jan's answer, I found strpos() rather than strncmp() for checking the widget name (it's faster.. ) Following you'll find a similar function (working & tested) that will take you to the same result: add_filter( 'sidebars_widgets', 'hide_widgets' ); function hide_widgets( $excluded_widgets ) { if ( is_page() /* Or whatever */ ) { ...


0

@import is not good solution AFAIK it takes a bit more time to download @import link and then process it, so you gonna have a little bit of network bottleneck. I'd go with default style.css file where you have all wordpress required meta data and then renamed diginomics.com/css/style.css to gobal.css and linked it with absolute link. Such semantic naming is ...


0

In a nutshell there are two basic approaches to this: Build elsewhere and upload (in one way or another) result to the target server Do everything right on target server There is variety of solutions that will do either of this or some mix of the two. The simplest possible way for the conditions you had given (Bitbucket and server with Git) would be to: ...


0

If you're using an absolute reference like that, you'd want to include the full file path, like http://diginomics.com/wp-content/themes/THEMENAME/css/style.css I believe any time you call the functions like get_stylesheet_directory() or get_stylesheet_directory_uri() it will return the path for the current theme. Just keep in mind that all themes need a ...


0

Well you can make a single template for the entire site and may call different page content in different <div> using this code: <?php $page_id = 47; $page_data = get_page( $page_id ); echo $page_data->post_content ; ?>


1

Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right direction! As You can see below I used the get_page_template_slug(); and str_replace() to filter through the templates used per page. Can someone Verify that this is a viable option? $args = array ( 'post_type' => 'page', ...


0

You can add all your post types in an array as a variable, and then pass that through a foreach loop $post_types = array('members','post','testimonial'); foreach ($post_types as $type) { if( $post_type == $type ) wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true); //"TRUE"-ADDS JS TO FOOTER }


0

You have to use OR(||) operator to test for each of the condition. OR returns true if any of the condition is true if ( ($post_type == 'members') || ($post_type == 'post') || ($post_type == 'testimonial') )


0

Try this: if( in_array($post_type, array( 'members','post','testimonial' ) ) ) wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true); } Function in_array is used to check if current post type is in the array of allowed post types.


0

Did you try this ?Hope this will work. add_filter( 'the_content', 'cd_display_quote' ); function cd_display_quote( $content ) { // We only want this on single posts, bail if we're not in a single post // if( !is_single() ) return $content; // We're in the loop, so we can grab the $post variable global $post; $data = ...


1

In those themes there's a screenshot.png or screenshot.jpg that gets used. I would recommend using an 880x660px image ( for the aspect ratio, and for retina displays )


1

There are several plugins to accomplish this. Like https://wordpress.org/plugins/wp-better-emails/ or http://wordpress.org/plugins/wp-email-template/


0

This code has them all removed. Simply add back what you want to return in the code which goes in your functions file add_filter( 'comment_form_defaults', 'wpsites_remove_comment_form_allowed_tags' ); function wpsites_remove_comment_form_allowed_tags( $defaults ) { $defaults['comment_notes_after'] = ''; return $defaults; }


1

There's a filter-hook that allows you to run some checking before comment is posted so you could use it too : add_filter('preprocess_comment', 'wpse_158147_check_new_comment'); function wpse_158147_check_new_comment($commentdata){ $commentdata['comment_content'] = preg_replace("/<tag(.*?)>(.*)<\/tag>/", "$2", ...


0

Try hooking to a later hook for comment tags. function my_comment_tags() { global $allowedtags; $allowedtags = array( 'strong' => array(), 'em' => array(), 'a' => array( 'href' => array (), 'title' => array ()) ); } add_action('comment_post', 'my_comment_tags');


0

Looks like this is a core issue with BP and only affects custom commenting like I did. I'm going to mark this as resolved as they're aware of the issue now.


2

Modify your installation such that your custom Farsi language files are associated with a non-standard WPLANG value. For example, instead of the standard 'fa_IR', maybe try something non-standard like 'farsi_IR' (or even 'myCustomFarsi_IR'). This way, when new WordPress versions are released for the "official" Farsi version, you will no longer get ...


0

I got the solution for this question. I need to apply there Isotope append method, when adding posts to the frontend. Here is the Isotope append method.


1

The second one is revision. It means the changes that you made, but didn't save. Wordpress saves that as revision post. There might be more than one revision post if you make more changes without updating the post. You don't need to worry about that. It's all in background and won't affect you in any way.


1

WordPress as a project has extreme commitment to backwards compatibility. Whatever new things you add the old things need to work still. Whatever things you change still need to work in old way as well. So regardless of how WP started as non–MVC application, it cannot become one without retaining all of its non–MVC ways. Which makes it pretty pointless ...


2

WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside "Blog pages show at most". You can override that number in your custom queries a couple of ways but I would first recommend against the use of query_posts() ( take a read at the link for the reasons why) in favour of ...


0

Try this: query_posts( 'posts_per_page=-1' ); Just a head up, you shouldn't be using this function here, do whatever you want, but is recommender to use WP_Query or get_posts


1

According to the Codex, your custom page template must have a header containing the name of the template. All page templates must be named in this way, or they will not appear in the "Template" dropdown. Here's an example, make sure your custom template has a header in this format: <?php /* Template Name: My Custom Page */ // Your custom page template ...


2

May be something is wrong on your page template file. Have your added page template name at top of the page like this: <?php /* Template Name: My Custom Page */ Try with this and check once again. You can check WordPress document for creating custom page template. Check this link: Page Templates


2

You get as much control as any other plugin. if you need some code to be executed before any other you can't just include it in the theme and you will need the user to manually install it. Those files are reffered to "dropin plugins" and that is the best documentation I could find http://wpengineer.com/2500/wordpress-dropins/ (shame on the codex for not ...


0

The global $wp object contains the current request, which can be used to get the current URL anywhere on the site. A helper function like the following demonstrates how this works: function wp157715_current_url() { global $wp; $current_url = trailingslashit( home_url( $wp->request ) ); return $current_url; }


0

you can use bloginfo('url') but also can use get_option function, check documentation: http://codex.wordpress.org/Function_Reference/get_option and by the way we cannot access your localhost :)


0

As posed in question the way to retrieve the current URL to the root of the site would be home_url() for site's front-end. However there are multiple functions that deal with URLs to specific kinds of pages. It's not clear what you are linking to (post? page? archive?), but there are likely specific URL-forming function for it which should be used over ...


1

bloginfo('url') should get you the URL for the installation. EDIT: I guess you could also use get_permalink()


1

You're not adding HTML code to your file, you're adding invalid PHP. To recap, in PHP everything between <?php and ?> is PHP code. So this is valid PHP: <?php echo 'hello world';! ?> This is also valid: <b><?php echo 'hello world'; ?></b> This is not valid: <?php <b> echo 'hello world'; </b> ?> Why? ...


2

You are including HTML elements without closing the php tags. Also, the last one should be endif, not endwhile. <?php if (have_posts()) : ?> <ul> <?php // Start the Loop. while (have_posts()) : the_post(); /* * Include the post format-specific template for the content. If you want to ...


0

This seems to be what you are looking for Take into account that you probably will have to add a new file to your theme's directory. The rest is easy, just create a page and select the right template.


1

For historical bloggy reasons, the_date in WordPress won't show the same date twice in a row. This is for grouping purposes. The fix is easy: Use the_time instead. It behaves exactly the same as the_date, but without the internal historical logic. Also no need to rewrite any complicated code, just change three characters. :) Note: the_time is missing the ...


1

As it says right there is its inline documentation — the function is meant to only output the result "once per date". In typical chronological loop of posts it will "collapse" for posts made on same day. In less typical loop it might lead to pretty bizarre outputs. If you dig far and deep enough in version control history you might be able to dig up ...


0

first of all you named your page template "Post Archive" not "All Posts"! and for a quick and easy solution check the link below: Creating an Archive Template


0

wp_get_archives() can not display post date, but you can force wp_get_archives to display date by using hook. Put the following function at the end of your custom template file or functions.php file - function wpse_the_title($title, $id){ if( $date = get_the_date('d/m/Y', $id) ){ $title = sprintf('%s - %s', $date, $title); } return ...


1

Constants can not be redefined that easily. http://stackoverflow.com/questions/8465155/redefine-constants-in-php So, the constants from child themes will be used instead of parents one. Though, there will be a warning, but that shouldn't create any problem if you disable warning. You should add constants like this if you don't want any warning: if ( ...


0

Never change content without the user's specific manual request, and never ever delete anything from the DB that you haven't created. So the only question left is how to create you sample content. The cleanest way is to provide an exported sample that can be imported into WP. The only problem with this approach is that it requires the installation of the ...


0

404 errors are handled browser site and has nothing to do with Wordpress. When nothing is returned from the request, the browser triggers a 404 action and displays a 404 not found error page By default, if no custom 404 page exists on the site, the browser will display its own default 404 page. For further reading, check out: Creating an Error 404 page


0

Had the same problem, got solved here I just add the code from the last comment in my child themes functions.php, now embeds are working fine. Seems to be necessary because of automatically added paragraphs The code for functions from the reference mentioned above: add_filter( 'the_content', 'my_autoembed_adjustments', 7 ); /** * Add a new line ...


8

Do not use constants for that. Do not use global constants at all. There are two types of constants: class/interface constants and global constants. Constants in classes or interfaces are fine and sometimes useful. An overly simplistic example: interface Requirements { const MIN_PHP_VERSION = 5.4; public function php_is_good(); } class ...


2

My guess would be that you are remove the action before it is actually being added in the parent theme. The parent's theme functions.php file gets loaded after the child one so it looks like your removing something that is not there yet. The 3rd parameter in remove_action() is the priority. Try playing around with that number - the default is 10 - to see ...



Top 50 recent answers are included