Tag Info

New answers tagged

0

If you look at the source code of get_the_archive_title(), you will see that there is a filter supplied, called get_the_archive_title, through which you can filter the output from the function. You can use the following to change the output on a category page add_filter( 'get_the_archive_title', function ( $title ) { if( is_category() ) { ...


0

You could use echo '<h1 class="page-title">' . single_cat_title( '', false ) . '</h1>';


2

All you need is to enable permalinks. I strongly recommend switching to permalinks: /%postname%/ The old links will still work. (In fact, every single permalink type is just an alias for the default one: ?p=%post_id% ). Being able to give people easier to remember links to pages is a secondary reason. The main one should be boosting page rankings in ...


1

If you tried to create a static file and then load it like a normal file, you may have had trouble because a WP page as we call it, is actually not actually 1 file, but rather a lot of files that tell Wordpress how to put together information queried from the database based on the query that is used in the URL. Most modern WP installs use pretty-links which ...


0

Use like this: <?php while ( have_posts() ): the_post(); // Display post if ( have_posts() ): the_post_thumbnail(); //call image that you set in featured image in each post on right sidebar of admin panel. the_content(); //call content endif; endwhile; ?>


0

You might try this: function add_author_edit_link( $wp_admin_bar ) { if ( is_author() && current_user_can( 'add_users' )) { $currentUserID = get_current_user_id(); $args = array( 'id' => 'author-edit', 'title' => __( 'Edit Person' ), 'href' => '/wp-admin/user-edit.php?user_id=' . ...


1

You could try this modification of your code: function add_author_edit_link( $wp_admin_bar ) { if ( is_author() && current_user_can( 'add_users' ) ) { $args = array( 'id' => 'author-edit', 'title' => __( 'Edit Author' ), 'href' => admin_url( sprintf( ...


0

I'd recommend using the template_include filter as opposed to template_redirect, as using this hook means that you don't redirect the user but rather just present them with the template that is requierd. add_filter('template_include', 'my_custom_template_redirect', 99); function my_custom_template_redirect($template){ global $post; if(is_single() ...


0

You can also try to check plugin is Active or Not $PluginList = get_option('active_plugins'); $Plugin = 'PLUGIN_DIR/FILE_NAME.php'; if ( in_array( $Plugin , $PluginList ) ) { // Plugin 'mg-post-contributors' is Active } Also try below code for simplicity if ( is_plugin_active( 'PLUGIN_DIR/FILE_NAME.php' ) ) { //plugin is activated }


0

It turns out that the problem was that I de-registered jQuery in my functions.php file. I re-registered the correct version of jQuery by calling wp_register_script('jquery', ...) and suddenly, everything worked perfectly.


-3

-EDIT- Because some people need more "information" On this Thursday January 22nd 2015, you can find on the following 2 links how to setup PHPStorm to work with WordPress (I'm sorry if later on those links don't work anymore). https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm ...


0

save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was edited. For example, quick edits use $_POST. Since this action is triggered right after the post ...


1

This might not answer your question directly, but there are a few big issues you have to address here. Adult sites get a lot of traffic (usually a lot of fake, hacker and spam traffic), which means a lot of wasted space in your db and slower loading times if you are going to make use of ip addresses to save a first time visit. Think about it, if recieved ...


0

you can use post_status. post_status A comma-separated list of post status types that should be included. For example, 'publish,private'. possible values are: (publish|inherit|pending|private|future|draft|trash) or you can also play with: include Only include certain Pages in the list generated by wp_list_pages. This parameter takes a comma-separated ...


0

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name: function post_author_title( $post_title, $post ) { if( $post->post_type == 'your_post_type' ) { $user = wp_get_current_user(); ...


1

wp_get_attachment_image this function can help you. Using this function, your file should like below... entry-summary.php <?php the_title( '<h1 class="clear">', '</h1>' ); ?> <?php if ( has_post_thumbnail() ) { $attachment_id = get_post_thumbnail_id( get_the_ID() ); $default_attr = array( 'src' => $src, ...


1

I normally use something like: if ( current_theme_supports('post-thumbnails') && has_post_thumbnail() ) { $post_thumb_id = get_post_thumbnail_id($id); $image_data = wp_get_attachment_image_src($post_thumb_id, 'thumbnail'); $attr_title = esc_attr($title); $image = <<<HTML <div class="thumbnail"><img ...


2

WP plugins are meant to be loaded in context of WordPress core load. They won't work as vanilla PHP, unless you purposely abstract some parts completely away from WordPress. The typical practice is to have actual working WP installation locally and develop in its context.


0

EDIT: By default WordPress will crop thumbs to 150x150px when they are uploaded. When you uncheck the box in Settings>Media WordPress will not regenerate existing thumbnails, it will only generate proportional images when you upload new images. In short I believe your issue is not with the code you are using to display the thumbnail but the image itself. ...


1

You can collect image attributes using "wp_get_attachment_metadata", see below example as starting point function mytheme_post_thumbnail( $size = 'post-thumbnail', $attr = '', $post_id = null ) { if ( has_post_thumbnail( $post_id ) ) { $meta = wp_get_attachment_metadata( get_post_thumbnail_id( $post_id ) ); $args['width'] = ...


0

Just got a solution: Just add this code to your functions.php and replace '_metainfo' by your meta information and 'posttype' by your posttype. function add_meta2url( $link, $post ) { $post_meta = get_post_meta( $post->ID, '_metainfo', true ); if ( 'posttype' == get_post_type( $post ) ) { $link = $link . '#' .$post_meta; return ...


1

You are using it wrong. add_action: attachs a function to an action hook. In your code, you are attaching alter_item funtion to admin_menu action hook. So, when admin_menu action happens, alter_item function is executed. According to codex, no parameters are passed to functions attached to admin_menu. So, the parameters your are trying to use in alter_item ...


0

try this code: if( get_theme_mod('your_setting_name') ){ //your code }else{ //your code } Note: get_theme_mod() return false if no value exist for your setting


0

Have you tried: function my_members_only_shortcode($atts, $content = null) { if ( !is_user_logged_in() ) { $content = '<p>This content is for members only. Please log in or register first.</p>' . do_shortcode('[do_widget "Social Login" ]'); } return $content; } That should replace the content with your message and special ...


1

if you want to show only 2, put it as a value, like so: 'posts_per_page' => 2 For the newest posts, you need to change the sort using the order and orderby params: 'orderby' => 'date', 'order' => 'ASC' Details about orderby params here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters Also, you should avoid ...


0

so i removed the pagination by removing this from lower <?php get_template_part('inc/pagination'); ?> <?php else: ?> <h3><?php echo ot_get_option('no_artists'); ?></h3> then changed $ppp_artists = ot_get_option('ppp_artists'); to $ppp_artists = 2; which changed the number of posts to 2 however I need ...


0

To see the menu, you need to set it up in the wordpress admin side. Go to Appearance -> Menus You should see a "Manage Locations" tab. Select it. You should see your "Main Menu" location. Choose the menu that you created there. Select Save Changes. Since you used "theme-location" to set up drawing it, you need to set a menu to your theme location to ...


0

Hmm, I see you're using the get_categories() function to retrieve all categories. That function is returning an array with category objects. This means you have to edit the foreach loop, because $category is an object. $form_fields["custom4"]["html"] .= '<option value="' . $category->term_id . '">' . $category->name . '</option>'; Have ...


0

The way you're appending a foreach loop to a variable is not possible. Try this: $form_fields["custom4"]["html"] = "<select name='attachments[{$post->ID}][custom4]' id='attachments[{$post->ID}][custom4]'>"; foreach ($categories as $category) { $form_fields["custom4"]["html"] .= '<option value="$category">' . $category . ...


0

If you use do_action( 'woo_collections_menu' ); in the template, then your function must echo its value. Otherwise, you are returning the data into a black hole, nothing is outputting what you're returning. If you use a filter, then you should return the value. The point of a filter is to take a value, filter that value through a function, then do something ...


0

I still couldn't figure out how to return $woo_menu; with my first example code, but I realized things don't break if I keep the rest of the structure as far as the variable goes and just echo once at the very end. This seems to work for me. Whether this is good practice or not, leave me a comment, but for now, this is the solution I'm using. Thanks. ...


0

First, year is already a WordPress query var used for date-based archives, you should change that to something unique to prevent possible conflicts. To use your own query vars within rewrite rules, you need to add them to the list of known vars: function wpd_query_vars( $qvars ) { $qvars[] = 'my_year'; $qvars[] = 'make'; $qvars[] = 'model'; return ...


1

From my understanding of actions (as opposed to filters), an action simply does something and stops processing. No return value is actually made use of. You might change your code to be a filter by accepting an argument (say the html to append to) and then make a call like the following where you want to grab the code: $html_block = ...


0

Sidebar generator plugin is best solution for your logic? If you would like to add sidebar even in taxonomy or tag, you would need to create meta field or option field for that. Below example codes is good for static sidebar! <?php get_sidebar( 'left' ); ?> <?php get_sidebar( 'right' ); ?>


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

Thanks @shady-m-rasmy I used the code you mentionned, and it seems that the second foreach loop (below - in the custom template part) is not necessary as it is only executed once. foreach ($_FILES as $file => $array) { $newupload = my_handle_attachment($file,$pid); } So it only leaves with $newupload = my_handle_attachment( ...


0

As toscho already said, you need to load the file a template. Otherwise you can try to include the wp-load require('wp-load.php'); You can find it in the WordPress Root Directory - so perhaps you need to add the path to wp-load in the require. This should help you.


1

You can get the current term slug from the global query. You could do something like this: if( is_tax('cars') ) { //We are in "cars" taxonomy archive page, now get the queried term $term = get_query_var( 'term' ); show_post($term); }


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', ...


0

If, as you have ensured, the javascript files are correctly loaded, simply WordPress is not likely to be involved in your problem. That being said, if, as you also have ensured, the code is correct and there are no errors, I think that the problem can be related with the DOM being not ready. The code from java1.js code depends on DOM, so you must be sure ...


0

The Codex includes a useful page on AJAX in plugins which outlines how to send and receive an ajax request. The code below covers how you would trigger an event when the select field is changed and fire off the ajax request. Make sure you're getting and setting a nonce value. /** * Only execute after jQuery is loaded */ jQuery(document).ready(function ($) ...


0

I see nothing wrong with altering the title of these post formats to suit the needs of your editorial team and process. Unless changing the names would break theme functionality from rendering them properly. The idea behind these formats is that a theme can state which are supported and only those would be listed in the editor. From what I can tell ...


1

I am author of commenter data plugin. I have addressed your concern and released version 2.1 which allows you to set the capability. Please take a look and let me know if you have any further query.


5

I am not sure why your query is returning more IDs than necessary. The $args for get_users look correct. By default get_users does not support orderby=rand, but you can overwrite that option. See below: function random_user_query( &$query ) { $query->query_orderby = "ORDER BY RAND()"; } // Usage: [random_users how_many = 3] add_shortcode( ...


2

If you only want the size ( the width and the height ) of the image in the img tag like so <img src="source_of_your_image" width="500" height="250"/> Then use the following php code: $MySrc = "source_of_your_image"; $Myimg = "<img src='$MySrc' "; $TheImg = (array)getimagesize($MySrc); $Myimg .= $TheImg[3]."/>"; For more info on using ...


1

You have to know that child theme functions.php is loaded before parent theme functions.php. It means that inside a child theme functions.php parent theme classes are not available yet, so you get that fatal error. If the class is in parent theme functions.php you can use 'after_setup_theme' hook to wait for when the parent theme class is defined: ...


0

You should not have the () on the callback field. You shouldn't need the add_action so remove add_action('load_comments', 'custom_comments'); And try: wp_list_comments('type=comment&callback=custom_comments'); Also, you should extract the $args so they are available in your function: function custom_comments($comment, $args, $depth) { ...


0

At last I've fixed the issue. In my parent theme, the dev have used the following code if ( ! isset( $content_width ) ) { $content_width = 650; } which means if the value of $content_width has not set up yet then set it to 650. Now in my chield theme at the time of overwriting and mentioning image type I've just added few more lines like this: ...


0

Use '9999' as a height limit for the add_image_size function. Thus, you will have your ratio saved without cropping or squishing the image and only width limit will be followed. Height is required and has no default value (see here: https://developer.wordpress.org/reference/functions/add_image_size/)



Top 50 recent answers are included