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

cs1h on "Update Media Title"

$
0
0

Hi,

I am trying to write a piece of code that update the title and description of an image using PHP.

Currently I have some code that retrieves the image for a specific post and checks if the title is set, if it is not then I would like to add a title.

However I can not the relevant function or example of how this can be done.

If anyone can point me in the right direction I would be grateful.

Thank you in advance,
cs1h


Mrbigp on "Hard coding category to custom post type"

$
0
0

Hi,

I want to create a new custom post type for recipes. No problems there (havent done it yet )but I want any posts that use this custom post to be automatically assigned to the category 'recipe' and the admins cannot uncheck this - so whilst they can add this post to any categories, they can never remove it from belonging to the 'recipe' category.

Maybe one of the custom post type maker plugins do this already?

Cheers

ecigstogo on "How can I add a Read More link on PAGE (not POST)?"

$
0
0

Does anyone know how to add a "Read More -->" link into page content as opposed to post content? I know that it is very well documented how to add the Read More link into post content for blog pages or other pages that show blog post content, however I want to add a Read More link onto my home page (which is not a blog/post page). I tried using JQuery, however it clashed with other JQuery plugins within my site & did not work (made the page content area blacked out).

Has anyone every gotten a Read More link to work on a regular wordpress page (as opposed to a blog or post page)?

If so, can someone please give me step-by-step instructions how to do it?

I am open to adding plugins if I have to & to any custom code or hacks necessary.

Have been stuck on this for over a week.

Here is my site: http://ecigs2go.com/

As you may notice, the homepage is very wordy & is in desperate need of Read More links!

Thanks in advance to anyone who can help me.

biscuitpaper on "Trash"

$
0
0

Hello. How do I hide the "Trash" link for users with access as "Authors"?

Thanks.

codetempo on "PHP Variable with Theme Customization API"

$
0
0

Is it possible that i can make a live view on PHP Variable with Theme Customization API? Thanks!

from header.php

<div id="number"><?php echo get_theme_mod( 'numberInput' ); ?></div>

above is working fine on live preview but below code is not appearing on live

<?php
$mynumber = get_theme_mod( 'numberInput' );
$cars=array("Nothing","Volvo","BMW","Toyota");
echo $cars[$mynumber];
?>

from function.php (add control)

$wp_customize->add_control(
		'numberInput',
		array(
			'section'  => 'number_options',
			'label'    => 'Number',
			'type'     => 'select',
			'choices'  => array(
				'1'     => 'One',
				'2'     => 'Two',
				'3'   => 'Three'
			)
		)
	);

from theme-customizer.js

(function( $ ) {
	wp.customize( 'numberInput', function( value ) {
		value.bind( function( to ) {
			$( '#number' ).text( to );
		});
	});
})( jQuery );

directly link for the screenshot of code Screenshot

Menschitko on "WordPress default Recent Comments to have #disqus_thread suffix"

$
0
0

Hi there,
I am in need of a help from someone who would know how to change the URL output of comments in the default recent comments widget.
The URLs display the ID of comments in WordPress database, however, when using Disqus, the URL doesn't work and doesn't automatically scroll down.
All I need is to change this: http://yourdomain.com/your-article/#comment-314955
To this: http://yourdomain.com/your-article/#disqus_thread
The second URL doesn't need to have an ID attached to it.
Has anybody got any ideas about how to achieve this?
Many thanks! :)

NecNecco on "Am I on Hack Attemt?"

$
0
0

Hello all,

I am new to Support but proud to be a Wordpress'er.

I am seeing three weird url attempts in my server logs. URLs are below:

http://example.com/?p=325++++++++++++++++++++++++++++++++++++++Result:+chosen+nickname+"ExaxySwanna";+sent+(from+first+page)

http://example.com/?p=325++++++++++++++++++++++++++++++++++++++Result:+chosen+nickname+%22ExaxySwanna%22;+sent+%28from+first+page%29

http://example.com/?p=325++++++++++++++++++++++++++++++++++++++Result:+chosen+nickname+%22ExaxySwanna%22;+sent+from+first+page

Would you mind interpret what are they trying to do please? And do I need to get worried about this attempt?

Cheers

blogger323 on "Functinon to remove script tags"

$
0
0

I'm looking for a function to remove dangerous tags, such as script tags, from a HTML text. I believe this is a common action and there must be a predefined function. But I couldn't find it.

Could anyone tell me this kind of function?


rfmurphy81 on "How to Reference/Echo Attribute from Another PHP Function"

$
0
0

I am now looking to display JUST the view count and duration values for the video on the home/list pages (via loop.php) but having difficulty determining the appropriate PHP code to do this.

Here is the function that I've been using successfully for the post view:

add_shortcode('yt', 'getYoutubeDetails');

function getYoutubeDetails($atts) {
extract(shortcode_atts(array(
'video' => ''
), $atts));

// Get YouTube data via the API
$JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos?q=$video&alt=json");
$JSON_Data = json_decode($JSON);
$views = $JSON_Data->{'feed'}->{'entry'}[0]->{'yt$statistics'}->{'viewCount'};
$views = number_format($views);
$duration = $JSON_Data->{'feed'}->{'entry'}[0]->{'media$group'}->{'yt$duration'}->{'seconds'};

echo "<iframe width=\"1280\" height=\"720\" src=\"//www.youtube.com/embed/$video?showinfo=0&rel=0&modestbranding=1&theme=light&iv_load_policy=3&autohide=1&enablejsapi=1\" frameborder=\"0\" allowfullscreen></iframe>";
echo "Views: $views
Duration: ";
echo sec2hms($duration);
echo "

";
}

Within my post content, I tag my videos as [yt video="VIDEOID"]. I was hoping I could get the specific attribute for views/duration by using: '<?php echo GetYoutubeDetails($views) ?>' in loop.php, but that doesn't seem to work. Is there a way to structure this to pull in a specific attribute within the function? Would it be able to leverage the value being passed into the video attribute of the shortcode that's already in the post content?

I'd prefer to tap into the existing shortcode already in the post content (so I'm not having to maintain it two or more different places). However, if there isn't a way to echo the value of an existing function for a particular post in loop.php, I was thinking it may need to get handled via a custom field somehow.

Any suggestions for how to tackle this issue?

izzatiskandar on "How to make a direct link to a specific website when clicking on the post?"

$
0
0

I am using the Fifteen theme on WordPress, I'm trying to find the code that will allow me to get to a specific page when I click on the Post.

this the link to my website:

http://wagibo.com/

On the homepage, each post appears as a single photo. I need help in figuring out the code that will make each time I click on the photo, it will leads me to a specific link that I desire.

Thanks

eissahamalawy on "wordpress search problem no result"

$
0
0

hi all
i am new in WordPress , i have problem in search engine
i use pagination and custom post type in my site .
when i try search its give no result .
i don't know how solve this problem
this my code :
function.php
// category pagination
function wpa85791_category_posts_per_page( $query ) {
if ( $query->is_category() && $query->is_main_query() )
$query->set( 'posts_per_page', 8 );
}
add_action( 'pre_get_posts', 'wpa85791_category_posts_per_page' );

// pagination
function wpbeginner_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="navigation">

' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '
%s
' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '

';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '

' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '
%s
' . "\n", get_next_posts_link() );
echo '
</div>' . "\n";
}
and this code to post 8 subject .
index.php
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 8, 'paged' => $paged );
$wp_query = new WP_Query($args);
?>

and this in code
searchform.php
<h2>Search</h2>
<div class="content">
<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
<label for="s">Search for:</label>
<input type="text" class="field" name="s" id="s" />
<input type="hidden" id="searchsubmit" value="Search" />
</div>
</form>

please anyone help .

chafik73 on "Anti-spam: How to restrict characters on comments to Arabic characters only?"

$
0
0

Hi
Before swiching to WP, I had a simple web site with a comment scripts called commentics
The website being in Arabic, I used a simple technique to fight spam which was 100%
It is a code to makes sure that there is at least one Arabic character:

function comment_check_arabic ($comment) { //checks whether comment is arabic

if (!preg_match("/\p{Arabic}/u", $comment)) {
    error("The comment entered is not Arabic. Please write it in Arabic.");
}

} //end of comment-check-arabic function

How can do the same thing in WP ?

Will24_ on "Block specific IP range from specific page"

$
0
0

I know I'm asking a bit much here, but is there a way I can block a specific IP range from a specific page on my website? I want to block everyone from a certain city accessing a certain page.

funkoolow on "replace a link in footer generated by theme adding the "rel=something" parameter"

$
0
0

hello,
i'm trying to replace the link generated by the theme i'm using (responsive theme from cyberchimps.com) on my website http://www.mycambox.it, so that the G+ icon link on footer area becomes
<a href="blablabla" rel="SOMETHING">
instead of only
<a href="blablabla">

Googling around I found that adding this small piece of code to my functions.php

function replace_content($content)
{
        $content = str_replace('<a href="https://plus.google.com/+SablabItInformatica">', '<a href="https://plus.google.com/+SablabItInformatica" rel="publisher">',$content);
        return $content;
}
add_filter('the_content','replace_content');

should do the trick BUT it seems it works only for the the content among the central area (replacing arbitrary text instead of the link such as a name in the main content area works fine).

I think it's related to the fact that add_filter calls the_content section and all that's included in the footer is out of that, so can someone suggest me how to fix that or where to look to understand to what the footer area is "linked"?

sorry if my question is really bad explained but i'm not very much familiar with hacking wp actually nor english native speaker.

Thanks in advance for any help.

lodestar on "Auto categorize last N rolling posts"

$
0
0

I want my blog to show the latest post full-width, the previous 2 side-by-side below, and the remaining posts linearly below that. I know I can do this using categories and a theme like Divi. So how can I get this to happen each time I post:

Assign new post to cat. 1, post 2 to cat 2, post 3 to cat 3, and uncategorize post 4 (which was post 3, are you with me?). Ideally this should be parameterized to support any value N for the number of latest posts to be so identified. I see the desired visual effect on many blogs, surely they are not all having to remember to manually recategorize the last few posts with every new post? Apart from the danger of forgetting to do this and so hiding some posts altogether, how could you post this way by email? Thanks! Dick


tukinu on "Add user page to custom menue page"

$
0
0

Hi,

I have a custom user management and would like to add a sub menu page to my custom top level menu page, like:
My Plugin
- My plugin users
how can I do this?

Thanks a lot

pondpnds on "Dashboard hacked"

$
0
0

Hi guys,

I have been reading all kinds of hack-fixing recommendation, but frankly I'm an amateur. My 6 wordpress sites have been hacked by this same Iranian guy but in different outcomes. I successfully fixed 3 of them, however I can't seem to find any solution for this one:

When I logged in, the dashboard look like this

I re-upload wordpress manually and checked all uploads folder but I can't seem to find anything.

Please advise.
Thank you so much.

AS1 on "Responsive Theme Deforms Imbedded Image"

$
0
0

Take a look at what imbedded images Im referring to please, http://fairmountfinance.com/rates/

Images look fine on a windows laptop, looks fine on an ipad, does not look fine on the iphone,even though the rest of the website without those imedded images does.

How can I resolve this problem?

Thank you in advance.

frogy6 on "Custom Postype - Category archive"

$
0
0

Guys...

I use magic fields 2 and able to create a set of category for each custom post type.
also manage to get archive of category from 1st custom post type (workout).

When try on 2nd and 3rd custom post type i cant figure out how.

Here is what i have in functions.php


add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if(is_category() || is_tag()) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else $post_type = array('post','workout'); // replace cpt to your custom post type
$query->set('post_type',$post_type);
return $query;
}
}

and here is the category list


<?php $customPostTaxonomies = get_object_taxonomies('workout');
if(count($customPostTaxonomies) > 0)
{foreach($customPostTaxonomies as $tax)
{$args = array(
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'taxonomy' => $tax,
'title_li' => ''
); ?>

<ul id ="subnav">
<?php wp_list_categories( $args ); ?>

<?php}
}
?>

Thanks...

streettb on "Anchor links, menu, and highlight current"

$
0
0

I'm trying to resolve a problem with anchor (or jump) links in the main wordpress menu.

If I place a number of jump links to the same page within the menu, it highlights all of the jump links to that page, instead of the one clicked. This is an issue when I navigate to the page with a number of jump links via the menu from another page Is there a workaround to this issue?

I know this has something to do with the php inserting the current-menu-item class to highlight a link in the menu based on the URL of one's page, but is there a way to filter out current-menu-item class based on the # for the anchor links?

Viewing all 8245 articles
Browse latest View live




Latest Images