Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

Settler11 on "delete_theme example?"


lmlorca on "query var redirects to post list, cant use custom query var"

$
0
0

If y register a query var:

function add_query_vars_filter( $vars ){
  $vars[] = "my_var";
  return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );

And then I try to use it on my static front-page:

http://www.mysite.com?my_var

It returns the post list like if it was the blog page. Is there any way to use query var on a static front page?

webdev00 on "Instead of lightbox set main picture to clicked picture in gallery list"

$
0
0

On such a page as this : https://dev.quaislaurentiens.com/boutique/qp-300/

I'd like to have the bottom row of pictures set the central image when clicked on.

And I'd untick "use lightbox".

right now if I do and leave as-is clicking on the picture simply sends you to the address of the picture.

sitaraine on "Changing the header from Static Image to an Image slider"

$
0
0

Theme: Singl
Plug-In for the Slider: Ultimate Responsive Image Slider
Website: terrorchallenge.ca

I am trying to alter the header on my "Teams" and "Sponsor" pages so it is an image slider rather than the static logo that can be seen on the home page and I am struggling to find a solution. I'm just not sure where to start and any help would be fantastic.

Chris on "Adding schema support to TinyMCE (partial solution)"

$
0
0

So, like many other SEO-minded people who are hard-coding their schema into their posts, I've found that the TinyMCE editor automatically strips schema markup when switching between Text and Visual post editor views, which is frankly incredible in 2016.

After some searching, I found this partial solution, which is apparently taken from here. As one of the commentators on the latter page points out, there is a small error in the code, which is corrected as follows (with some code added):

// Prevent TinyMCE from stripping out schema.org metadata
function schema_TinyMCE_init( $in ) {
	/**
	 *   Edit extended_valid_elements as needed. For syntax, see
	 *   http://www.tinymce.com/wiki.php/Configuration:valid_elements
	 *
	 *   NOTE: Adding an element to extended_valid_elements will cause TinyMCE to ignore
	 *   default attributes for that element.
	 *   Eg. a[title] would remove href unless included in new rule: a[title|href]
	 */
	if( ! empty( $in['extended_valid_elements'] ) ) {
		$in['extended_valid_elements'] .= ',';
	}

	$in['extended_valid_elements'] .= '@[id|class|style|title|content|itemscope|itemtype|itemprop|datetime|rel],div,dl,ul,ol,dt,dd,h2,h3,h4,li,link,meta,span,a[rev|charset|href|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]';

	return $in;
}
add_filter('tiny_mce_before_init', 'schema_TinyMCE_init' );

Now, I should also mention that in my search, I found this workaround to simply add a Custom Field with the desired schema markup. However, this is not a proper solution for me, because it doesn't allow you to enter the markup directly into the post body.

All schema elements seem to work for me so far, except for the <meta> element. I'm a bit dumbfounded why this element alone fails to work (with or without the optional closing "/"), so I was wondering if anyone could enlighten me as to why this is, and hopefully even provide a solution.

Thanks for your time!

ronc0011 on "How to show Categories?"

$
0
0

I’m trying to get the list of Categories to display in the Categories widget.

I’m developing this site locally on my laptop… Apache, MySQL, PHP 5.
I found a post here on this forum suggesting I could edit this line found in the header.php file…

<?php wp_list_categories('title_li=&exclude=' . $GLOBALS[asides_id]) ?>

The suggestion was that it should be changed to this…

<?php wp_list_categories('title_li=&exclude=&hide_empty=0' . $GLOBALS[asides_id]) ?>

However there no such line in header.php in fact no “wp_list_categories…”
The only place I find any such line is in sidebar.php and sidebar2.php. and those lines read as so…

<?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?>

Apparently in the above mentioned suggestion the edit used the addition of this bit…

&hide_empty=0

And presumably that will cause WP to display all the Categories I’ve created, regardless of whether or not they have any content i.e. “post”. In other words, empty categories.

blueplanetphoto on "wp-includes/formatting.php - where is it to resolve htmlspecialchars() warning"

$
0
0

In the Pinnacle theme, the home page header graphic has this warning where the "Welcome" message should be:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/content/69/6454569/html/IMARRIEDTHEWAR/wp-includes/formatting.php on line 3582

I cannot locate the wp-includes/formatting.php file in the editor. Where can I find this file and how can I remove the warning?

Or is this possibly an issue that needs to be solved with the Wordpress host?

Thank you.

sweetlena on "meta_value meta_value_num not sorting by most recent"

$
0
0

Hi, with the code below, my most recent posts are going to the bottom. But I'm wanting to have the ones I add most recently go to the top of the page??

$args = array(
	'post_type'		=> 'code',
	'post_status'	=> 'publish',
	'posts_per_page'=> coupon_get_option('shop_listing_per_page'),
	'code_category'	=> get_query_var( 'term' ),
	'meta_key'		=> 'code_expire',
	'orderby'		=> 'meta_value meta_value_num',
	'order'			=> 'asc',
	'paged' 		=> $cur_page,
	'meta_query'	=> array(
		'relation'	=> "AND",
		array(
			'key' => 'code_for',
			'value' => 'all_users',
			'compare' => '='
		),
		array(
			'key' => 'code_shop_id',
			'value'	=> $shop_id,
			'compare'	=> '='
		)
	)
);

kkmarch7 on "Anchor links linking between Tab content"

$
0
0

Hi I am running the Avada theme and using the tabs function. I want to add anchor links to content within one tab and have it link to specific content within another tab. This would mean the anchor link would have to open the tab the anchor is sitting in. Is this possible? Is there a Tab plugin that has this capability?

Thank you for your time

bnvt on "Override plugin widget class"

$
0
0

One plugin we use has some widget declared as

if ( ! class_exists( 'thewidget' ) ) {
	class thewidget extends WP_Widget {...}
}
add_action( 'widgets_init', create_function( '', 'register_widget( "thewidget" );' ) );

We need to override this widget code (not creating an alternate version, but actually replacing it with the same name but different code) but we don't know how to plug our own version of thewidget in either our theme's functions.php or our, preferably, a custom plugin.
If we declare our own thewidget class, it throws a 'Cannot redeclared class...' error; we understand this is because at this point the plugin function has already run and the class already exists.

We've tried wrapping our class declaration in a function and hooking this at various points to get our class declared before the plugin's, but to no effect, it either is too late or gets ignored:

function thewidget_override() {
	class thewidget extends WP_Widget {...}
}
add_action('muplugins_loaded', 'thewidget_override', 10);

(this is ignored)

So, if our approach is correct, where should we hook our class definition?
Else, what would be the correct way to override this code?

Thanks a lot for your help.

hedii on "Custom user roles translation not working"

$
0
0

Hi,
I am writing a plugin to create custom user roles and to remove wordpress default user roles except the admin one.

Everything is ok, but custom roles are not translated in the wordpress back-office (in user profil for example, or in settings=>general=>default role).

My plugin code is translation ready: i have created a .pot file and .po and .mo myplugin-fr_FR local. Translation files are ok, because i can see translated description and plugin name in admin plugin page.

/*
Plugin Name: My Website User Roles
Description: Custom user roles and capabilities for my website.
Version:     1.0
Author:      me
License:     GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my_website_user_roles
Domain Path: /languages
*/
class My_Website_User_Roles {

    public function __construct() {
        // on activation
        register_activation_hook( __FILE__, array( 'My_Website_User_Roles', 'activate' ) );

        /** other stuff like deactivation, etc... */

        // translation
        add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
    }

    public function load_textdomain() {
        load_plugin_textdomain( 'my_website_user_roles', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    }

    public static function activate() {
        // remove wp default roles except admin
	remove_role( 'editor' );
	remove_role( 'author' );
	remove_role( 'contributor' );
	remove_role( 'subscriber' );

	add_role(
		'basic_contributor',
		__( 'Occasional Contributor', 'my_website_user_roles' ),
		array(
			'read'         => true,
			'edit_posts'   => true,
			'delete_posts' => true,
		)
	);

	add_role(
		'expert_contributor',
		__( 'Expert Contributor', 'my_website_user_roles' ),
		array(
			'read'          => true,
			'edit_posts'    => true,
			'delete_posts'  => true,
			'publish_posts' => false,
			'upload_files'  => true,
			'edit_others_posts' => true,
			'edit_published_posts' => true,
		)
	);

	add_role(
		'moderator',
		__( 'Moderator', 'my_website_user_roles' ),
		array(
			'read'                   => true,
			'edit_posts'             => true,
			'delete_posts'           => true,
			'publish_posts'          => true,
			'edit_published_posts'   => true,
			'delete_published_posts' => true,
			'moderate_comments'      => true,
		)
	);
    }

}

On my languages directory, i have created my_website_user_roles-fr_FR.po and my_website_user_roles-fr_FR.mo files that should translate Occasional Contributor to 'contributeur occasionnel', Expert Contributor to 'contributeur expert' and Moderator to 'modérateur'.
But in the wordpress admin back office, custom user roles are in english but not in french.
Localisation files are loaded because they also translate the plugin description and i can see the description in french on the plugins page.

How can i see the custom user roles in a local language on the back office ? what am i doing wrong ?

kodden on "Pagination only inside CATEGORY"

$
0
0

Hello all!

Please somebody can help me change the code below to navigate (next/previous) only inside the category the user are in. I'm using JustWrite theme.

funcitions.php

/*  Post pagination
/* ------------------------------------ */
if ( ! function_exists( 'ac_post_nav_arrows' ) ) {

	function ac_post_nav_arrows() {
		global $post;

		$prev_post = get_next_post();
		$next_post = get_previous_post();

		if( $prev_post ) {
			$prev_post_id = $prev_post->ID;
			$prev_post_url = get_permalink($prev_post_id);
		};
		if( $next_post ) {
			$next_post_id = $next_post->ID;
			$next_post_url = get_permalink($next_post_id);
		};

		echo '<div class="post-navigation clearfix">';

		if( $prev_post ) {
			echo '<a href="' . esc_url( $prev_post_url ) . '" class="prev-post" title="' . __( 'Previous Post', 'justwrite' ) . '">' . ac_icon('angle-left', false) . '</a>';
		} else {
			echo '<span class="prev-post">' . ac_icon('angle-left', false) . '</span>';
		}

		if( $next_post ) {
			echo '<a href="' . esc_url( $next_post_url ) . '" class="next-post" title="' . __( 'Next Post', 'justwrite' ) . '">' . ac_icon('angle-right', false) . '</a>';
		} else {
			echo '<span class="next-post">' . ac_icon('angle-right', false) . '</span>';
		}

		echo '</div>';
	}

}

single.php

// Next - Previous Post
ac_post_nav_arrows();

Thanks!
Kind regards!

racetoread on "Error"

$
0
0

I know nothing about websites and was handed the duty of keeping the website up.
I am receiving the following error and have absolutely no clue on what to do.

Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

I'm not even able to log into my site.

can anyone assist me. let me remind you again I know nothing about anything to do with websites.

geduardcatalin on "standalone script"

$
0
0

Hi, Eduard, new here...
So, basicaly, what I want to do is to make a script.php file, and when I run it I want to do the following:
- remove or change the logo (the one in the top-left corner of the admin screen)
- remove or change some other elements like Help in the top-right side of the admin menu), or other elements.

this script.php, basicly, will modify the wordpress core with simple php file handling (fopen, fwrite, fclose, etc.)

Now, the question is: Where do I want to insert this code? In what core wordpress file do I want to insert the code to remove or change the things I mentioned above?

P.S. I know that this is relatively easy to do with a plugin, but I don't want to do that because I already know. I want to learn how WordPress work.

posc2016 on "Creating Title and Meta Description Manually from custom PHP"

$
0
0

I am working on a site http://www.einhorns-epic-cookies.com. I am trying to change the Title and Meta Description for the individual pages but the code shown below prevents me from dong that and the Title and Meta Description seem the same for all the pages. Any help would be gretaly appreciated.

<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="<?php bloginfo('charset'); ?>" />
<meta property="og:type" content="website">

<?php if(is_single()) : global $post; ?>
<title><?php echo WP_SITENAME; ?> | <?php single_post_title(''); ?></title>

<meta property="og:site_name" content="<?php echo WP_SITENAME; ?>"/>
<meta property="og:title" content="<?php single_post_title(''); ?>" />
<meta property="og:url" content="<?php the_permalink() ?>" />
<meta property="og:description" content="<?php echo htmlentities(strip_tags($post->post_content)); ?>" />
<?php
if (has_post_thumbnail()) {
  $img_array = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID));
  $og_thumb = $img_array[0];
}
else {
  $og_thumb = TEMPLATEDIR.'/assets/images/og.jpg';
}
?>
<?php elseif(is_home()): ?>
<title><?php bloginfo('name'); ?> | Cookies. Comics. Unicorns.</title>
<meta name="description" content="<?php echo WP_SITENAME; ?> | Cookies. Comics. Unicorns.">
<meta property="og:site_name" content="<?php echo WP_SITENAME; ?> | Cookies. Comics. Unicorns."/>
<meta property="og:title" content="<?php echo WP_SITENAME; ?> | Cookies. Comics. Unicorns." />
<meta property="og:url" content="<?php echo WP_HOME_URL; ?>" />
<meta property="og:description" content="<?php bloginfo('description'); ?>">
<?php $og_thumb = TEMPLATEDIR.'/assets/images/og.jpg'; ?>
<?php elseif(is_post_type_archive('cookies')): ?>
<title><?php bloginfo('name'); ?> | Cookies. Comics. Unicorns.</title>
<meta name="description" content="Cookie delivery to your door, a space unicorn comic book in every bag!">
<meta property="og:site_name" content="<?php echo WP_SITENAME; ?> | Order Cookies Online. Cookie Delivery. Cookie Gift Boxes."/>
<meta property="og:title" content="<?php echo WP_SITENAME; ?> | Order Cookies Online. Cookie Delivery. Cookie Gift Boxes." />
<meta property="og:url" content="<?php echo WP_HOME_URL; ?>/cookies/" />
<meta property="og:description" content="Cookie delivery to your door, a space unicorn comic book in every bag!">
<?php $og_thumb = TEMPLATEDIR.'/assets/images/og.jpg'; ?>
<?php else : ?>
<title><?php echo WP_SITENAME; ?> |  | Cookies. Comics. Unicorns.</title>
<meta name="description" content="<?php bloginfo('description'); ?>">
<meta property="og:site_name" content="<?php echo WP_SITENAME; ?>"/>
<meta property="og:title" content="<?php echo WP_SITENAME; ?>" />
<meta property="og:url" content="<?php echo WP_HOME_URL; ?>" />
<meta property="og:description" content="<?php bloginfo('description'); ?>">
<?php $og_thumb = TEMPLATEDIR.'/assets/images/og.jpg'; ?>
<?php endif; ?>
<meta property="og:image" content="<?php echo $og_thumb;?>" />

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum's parser.]


justasiam on "Adding a 'Comment' link to each article on home page"

$
0
0

I am running a WP 4.52 system with the 'Mountain Creek' theme and everything is running fine.

However, I have noticed that my users are not leaving many comments and it turns out to be because that did not see a 'Comments' link.

How do I add to my main WP page, a 'Comments' link at the bottom of each article w/o messing up the comments area on the individual article pages?

I have seen many old threads referring to a Comments Popup code, but I cann find any actual instructions (edit this file | find this code | insert this code there | etc...).

Ideas?

oivind on "Email about pending user, What capability?"

$
0
0

I have give Editors these capabilities:

$edit_editor = get_role('editor'); // Get the user role
        $edit_editor->add_cap('edit_users');
        $edit_editor->add_cap('list_users');
        $edit_editor->add_cap('promote_users');
        $edit_editor->add_cap('create_users');
        $edit_editor->add_cap('add_users');
        $edit_editor->add_cap('delete_users');

Now I would like the Editor to also receive email about a new pending user.
Is it possible?

jshrek on "Add rewrite rule to permalink structure"

$
0
0

I have a Custom Structure setup for posts in Settings > Permalinks as /%category%/%post_id%-%postname%

This works great for most of my posts, but there is one category that I want to remove the post_id from so it looks like this /%category%/%postname%

So if the category is CAT and the post-id is 123, then the permalink correctly looks like this:
mydomain.com/cat/123-my-great-cat-post

But if the category is DOG then I do not want the post-id, so it should look like this:
mydomain.com/dog/my-great-dog-post

I understand how to use actions and filters in my functions.php and I think I want to use either generate_rewrite_rules or post_rewrite_rules or add_rewrite_rule and add a new rule to the TOP.

I am honestly confused as how to write the rule though as regex is complicated and I do not understand it.

Any help appreciated.
Thanks

rewrite,rule,rules,generate,add,post,api,regex,generate rewrite rules,add rewrite rule

IlanF on "Updating private plugin changes plugin folder name"

$
0
0

I have a private with my own update server, up until recently all has been great and I could update it via WordPress dashboard, but now after updating WordPress changes the plugin folder name.
Take this simple plugin as an example (all it does is to trigger an update for itself)
I run the update, it does everything and after it's done I find the folder name for the plugin is private-plugin-X2HS23 instead of just private-plugin.
It doesn't look like something is wrong with the data I inject into the update transient since other plugins from the WordPress repository look the same. for example here is Akismet:

[akismet/akismet.php] => stdClass Object
                (
                    [id] => 15
                    [slug] => akismet
                    [plugin] => akismet/akismet.php
                    [new_version] => 3.1.11
                    [url] => https://wordpress.org/plugins/akismet/
                    [package] => https://downloads.wordpress.org/plugin/akismet.3.1.11.zip
                    [tested] => 4.5.2
                    [compatibility] => stdClass Object
                        (
                            [scalar] => stdClass Object
                                (
                                    [scalar] =>
                                )

                        )

                )

Any ideas what might have changed in the recent WordPress versions that could cause something like that? I think it started since 4.5

dylanhand on "Necessary to provide opt-in?"

$
0
0

If I'm making a plugin which clearly states that its only purpose is to provide external links to other websites (for example, a recommendations plugin which will link to external sites), is it still necessary to make an opt-in option to enable external links? Basically in my case, the plugin would have no functionality if that option is not enabled.

Is clearly stating that it will link to external sites not enough to get the plugin approved for posting in the plugin directory?

Viewing all 8245 articles
Browse latest View live




Latest Images