Tag Info

New answers tagged

-1

Make sure that you're logged in as admin Goto Settings General Settings Make sure that your site URL is "http://yoursitehere.com" If you have previously changed that it could cause you problems all across the board.


1

OK, after reading Rarst post i went with the taxonomy term option. It was very simple: Just after the register_taxonomy call, i added one line of code wp_insert_term('Featured','filter'); being filter my taxonomy. Then I modified the query in the template, adding the line 'filter' => 'Featured', inside the args. Now I only see the featured projects in ...


0

This sounds like stickies, but alas they don't work for custom post types. I would say if you are already using custom field for it, but not happy with interface then just fix the latter — interface. You can access custom field in admin just as you can in front end. Use it to make featured status more prominent in a fitting way. For example you could make ...


0

Generally said, there should nothing be happening before the get_header() call. So initiate your class if is_page() is true via wp_head action hook. Example: add_action( 'wp_head', 'initiate_my_class' ); function initiate_my_class() { if ( is_page() ) { //code } } Edit: As @AndrewBartel in his comment said you can globalize your variable ...


0

As I've explained elsewhere, you can modify the image sizes of the get_post_gallery() or get_post_gallery_images() with a simple filter: // Add a filter for full gallery size: add_filter( 'shortcode_atts_gallery','wpse_full_size_gallery' ); $gallery = get_post_gallery( get_the_ID(), false ); // Remove the filter: remove_filter( ...


0

The quick and simple method might be to create a custom page template and have the search form send the user to the page that you create with it. <?php /* Template Name: Location Results */ if ( isset($_REQUEST['search_field_name']) && !empty($_REQUEST['search_field_name']) ) { # Read and escape the input data # Do your query, grab your ...


1

Edit the according template file out of the Template Hierarchy, so in your case the template regarding the Category Display.


0

The correct way to do this is to: $('#upload-background-image-one').click(function() { formfield = $('#background-size-one').attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); // Take the selected image and insert only the src path into the text field. window.send_to_editor = function(html) { ...


0

As said, you should enqueue your style sheets like this in your functions.php in your theme: function adds_to_the_head() { // Our own unique function called adds_to_the_head wp_register_style( 'custom-style-css', get_stylesheet_directory_uri() . '/css/styles.css','','', 'screen' ); // Register style.css wp_enqueue_style( 'custom-style-css' ); // Enqueue ...


0

Try like this <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.min.js"></script> But it is a good practice to en queue your script in function.php Function Reference/wp enqueue script


0

I had forgotten to define the location of wp-content in my wp-config.php : define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content' ); define( 'WP_CONTENT_URL', 'http://'.$_SERVER['SERVER_NAME'].'/wp-content' ); define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/wp-content/plugins' );


0

You shouldn't need an action to add an editor style. Simple add the following anywhere in your functions.php: add_editor_style('css/editor-style.css');


1

$albumGenres = get_the_terms( $post->ID, 'discography_album_label' ); foreach ( $albumGenres as $albumGenre ) { echo $albumGenre->name; // or whatever value }


0

The established technique of passing data to JavaScript in WordPress is wp_localize_script(). Despite the name it's widely used for arbitrary data, outside of localization purposes. So it is certainly possible to retrieve the necessary data and pass it to the script in this way.


0

The line bellow probably does not read your action correctly that is why it returns 0 url: '<?php echo admin_url( 'admin-ajax.php' ); ?>', data: params + "&action=sendmail", Consider making an AJAX request similar to this: // the value of 'action' is the key that will be identified by the 'wp_ajax_' hook var data = { 'action': 'my_action', ...


1

You are using after_theme_switch action but the correct name is after_switch_theme. Also, you won't see the echo statements on after_theme_switch and switch_theme. To debug things in that hooks you can use, for example, error_log() function and look for messages in PHP error log file (you need to have errors "On" and/or WP_DEBUG enabled). I've tested this ...


0

The Isotope documentation about ImagesLoaded suggest two methods for this. I generally use the second one, which means: initializing Isotope and trigger layout after the images have been loaded. In my experience this works better, not that I have facts to proof it. Aside from that, I have it running this way successfully on a bunch of sites. The javascript ...


0

add_action('loop_start', 'slider_function'); function slider_function() { if ( function_exists( 'soliloquy_slider' ) ) { soliloquy_slider(); }} Something like this custom function added to your functions file will enable you to hook in the sliders template tag so it displays before the content. This assumes using the Soliloquy slider plugins template tag. ...


6

Try to keep the business logic out of the theme. Dealing with images is always an edge case, because they do affect presentation, which is usually a theme job. But the logic of how to get and order these images, the JavaScript parts and the backend are probably better in a separate code base. That is also easier for version control, because you can focus on ...


-2

This code also worked for me. Added !is_admin to Prevent view WP Dashboard function wpd_home_post_types( $query ){ if( !is_admin() && $query->is_main_query() ){ if ( $query->is_home ) { $query->set( 'post_type', array( 'post', 'natural-foods' ) ); } } } add_action( ...


0

Wordpress now provides this hook as after_switch_theme. You can use it like so: add_action('after_switch_theme', 'my_theme_activation'); function my_theme_activation () { // DO ALL THE THINGS } You can use the switch_theme hook to run code on theme deactivation as well. Source: http://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme


2

Add a function hooked to pre_get_posts which modifies post_type argument of the main query to add your custom post type. function wpd_home_post_types( $query ){ if( $query->is_home() && $query->is_main_query() ){ $query->set( 'post_type', array( 'post', 'natural_food' ) ); } } add_action( 'pre_get_posts', ...


0

I think that your structure here is wrong. I would completely remove your custom query from inside your loop and move it outside. Another option is to make use of other variable names in your custom query and making direct use of the WP_Post objects As @Milo already explained, your custom query is most probably affecting the value of your $post global ...


1

This is happening because the menu item is created with the page page "books", but the page currently displayed is post-type-archive-books (see classes in the body and menu item list). You can use something like function add_nav_menu_classes($classes, $item){ if( is_post_type_archive('books') && ($item->title == "Books" ) ){ $classes[] = ...


1

When you call setup_postdata($post);, that populates the global $post with the current post in your $categoryPosts result set. After the foreach terminates and you try to output the regular post data with template tags: <h2 class="section-blurb"><?php the_title();?></h2> <div class="info"> <?php the_content(); ?> ...



Top 50 recent answers are included